Example usage for javax.swing JComponent isFocusable

List of usage examples for javax.swing JComponent isFocusable

Introduction

In this page you can find the example usage for javax.swing JComponent isFocusable.

Prototype

public boolean isFocusable() 

Source Link

Document

Returns whether this Component can be focused.

Usage

From source file:Main.java

/**
 * Adds a component action.//from  w w  w.  j a v  a 2s .  c o  m
 *
 * @param component
 *            The compoennt to add the action to
 * @param action
 *            The action to add
 */

public static void addComponentAction(final JComponent component, final Action action) {
    final InputMap imap = component
            .getInputMap(component.isFocusable() ? JComponent.WHEN_FOCUSED : JComponent.WHEN_IN_FOCUSED_WINDOW);
    final ActionMap amap = component.getActionMap();
    final KeyStroke ks = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
    imap.put(ks, action.getValue(Action.NAME));
    amap.put(action.getValue(Action.NAME), action);
}

From source file:de.ailis.xadrian.utils.SwingUtils.java

/**
 * Adds a component action./*from w  ww .  j  a  v a  2 s  .com*/
 * 
 * @param component
 *            The compoenet to add the action to
 * @param action
 *            The action to add
 */
public static void addComponentAction(final JComponent component, final Action action) {
    final InputMap imap = component
            .getInputMap(component.isFocusable() ? JComponent.WHEN_FOCUSED : JComponent.WHEN_IN_FOCUSED_WINDOW);
    final ActionMap amap = component.getActionMap();
    final KeyStroke ks = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
    imap.put(ks, action.getValue(Action.NAME));
    amap.put(action.getValue(Action.NAME), action);
}