Java Code Examples for javax.swing.JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT

The following are Jave code examples for showing how to use WHEN_ANCESTOR_OF_FOCUSED_COMPONENT of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: CommitPanel.java   View Source Code Vote up 5 votes
@Override
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
    boolean ret = super.processKeyBinding(ks, e, condition, pressed);

    // XXX #250546 Reason of overriding: to process global shortcut.
    if ((JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT == condition) && (ret == false) && !e.isConsumed()) {

        Keymap km = Lookup.getDefault().lookup(Keymap.class);
        Action action = (km != null) ? km.getAction(ks) : null;

        if (action == null) {
            return false;
        }

        if (action instanceof CallbackSystemAction) {
            CallbackSystemAction csAction = (CallbackSystemAction) action;
            if (tabbedPane != null) {
                Action a = tabbedPane.getActionMap().get(csAction.getActionMapKey());
                if (a != null) {
                    a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks)));
                    return true;
                }
            }
        }
        return false;
    } else {
        return ret;
    }
}
 
Example 2
Project: incubator-netbeans   File: VCSCommitPanel.java   View Source Code Vote up 5 votes
@Override
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
    boolean ret = super.processKeyBinding(ks, e, condition, pressed);

    // XXX #250546 Reason of overriding: to process global shortcut.
    if ((JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT == condition) && (ret == false) && !e.isConsumed()) {

        Keymap km = Lookup.getDefault().lookup(Keymap.class);
        Action action = (km != null) ? km.getAction(ks) : null;

        if (action == null) {
            return false;
        }

        if (action instanceof CallbackSystemAction) {
            CallbackSystemAction csAction = (CallbackSystemAction) action;
            if (tabbedPane != null) {
                Action a = tabbedPane.getActionMap().get(csAction.getActionMapKey());
                if (a != null) {
                    a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks)));
                    return true;
                }
            }
        }
        return false;
    } else {
        return ret;
    }
}
 
Example 3
Project: incubator-netbeans   File: CommitPanel.java   View Source Code Vote up 5 votes
@Override
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
    boolean ret = super.processKeyBinding(ks, e, condition, pressed);

    // XXX #250546 Reason of overriding: to process global shortcut.
    if ((JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT == condition) && (ret == false) && !e.isConsumed()) {

        Keymap km = Lookup.getDefault().lookup(Keymap.class);
        Action action = (km != null) ? km.getAction(ks) : null;

        if (action == null) {
            return false;
        }

        if (action instanceof CallbackSystemAction) {
            CallbackSystemAction csAction = (CallbackSystemAction) action;
            if (tabbedPane != null) {
                Action a = tabbedPane.getActionMap().get(csAction.getActionMapKey());
                if (a != null) {
                    a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks)));
                    return true;
                }
            }
        }
        return false;
    } else {
        return ret;
    }
}
 
Example 4
Project: Equella   File: FlatterSpinnerUI.java   View Source Code Vote up 5 votes
/**
 * Returns the InputMap to install for <code>condition</code>.
 */
private InputMap getInputMap(int condition)
{
	if( condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT )
	{
		return (InputMap) UIManager.get("Spinner.ancestorInputMap");
	}
	return null;
}