javax.swing.JComponent#WHEN_ANCESTOR_OF_FOCUSED_COMPONENT源码实例Demo

下面列出了javax.swing.JComponent#WHEN_ANCESTOR_OF_FOCUSED_COMPONENT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FancyBing   文件: GuiUtil.java
public static void removeKeyBinding(JComponent component, String key)
{
    int condition = JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT;
    InputMap inputMap = component.getInputMap(condition);
    // According to the docs, null should remove the action, but it does
    // not seem to work with Sun Java 1.4.2, new Object() works
    inputMap.put(KeyStroke.getKeyStroke(key), new Object());
}
 
源代码2 项目: netbeans   文件: CommitPanel.java
@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;
    }
}
 
源代码3 项目: netbeans   文件: VCSCommitPanel.java
@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;
    }
}
 
源代码4 项目: netbeans   文件: CommitPanel.java
@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;
    }
}
 
源代码5 项目: iBioSim   文件: CloseTabPaneUI.java
static InputMap getMyInputMap(int condition) {
	if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
		return (InputMap) UIManager.get("TabbedPane.ancestorInputMap");
	}
	else if (condition == JComponent.WHEN_FOCUSED) {
		return (InputMap) UIManager.get("TabbedPane.focusInputMap");
	}
	return null;
}
 
源代码6 项目: lizzie   文件: BasicLizziePaneUI.java
InputMap getInputMap(int condition) {
  if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
    return (InputMap) UIManager.get("LizziePane.ancestorInputMap", lizziePane.getLocale());
  }
  return null;
}