javax.swing.text.JTextComponent#KeyBinding ( )源码实例Demo

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

源代码1 项目: dragonwell8_jdk   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码2 项目: TencentKona-8   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码3 项目: jdk8u60   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码4 项目: openjdk-jdk8u   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码5 项目: nextreports-designer   文件: SyntaxEditorKit.java
private JTextComponent.KeyBinding[] getDefaultKeyBindings() {
	return new JTextComponent.KeyBinding[] {
			new JTextComponent.KeyBinding(KeyStroke.getKeyStroke("control Z"), undoAction),
			new JTextComponent.KeyBinding(KeyStroke.getKeyStroke("control Y"), redoAction),
			new JTextComponent.KeyBinding(KeyStroke.getKeyStroke("TAB"), indentAction),
			new JTextComponent.KeyBinding(KeyStroke.getKeyStroke("shift TAB"), unindentAction)
	};
}
 
源代码6 项目: netbeans   文件: MultiKeymap.java
/** Loads key to action mappings into this keymap
* @param bindings array of bindings
* @param actions map of [action_name, action] pairs
*/
public void load(JTextComponent.KeyBinding[] bindings, Map actions) {
    // now create bindings in keymap(s)
    for (int i = 0; i < bindings.length; i++) {
        Action a = (Action)actions.get(bindings[i].actionName);
        if (a != null) {
            boolean added = false;
            if (bindings[i] instanceof MultiKeyBinding) {
                MultiKeyBinding mb = (MultiKeyBinding)bindings[i];
                if (mb.keys != null) {
                    Keymap cur = delegate;
                    for (int j = 0; j < mb.keys.length; j++) {
                        if (j == mb.keys.length - 1) { // last keystroke in sequence
                            cur.addActionForKeyStroke(mb.keys[j], a);
                        } else { // not the last keystroke
                            Action sca = cur.getAction(mb.keys[j]);
                            if (!(sca instanceof KeymapSetContextAction)) {
                                sca = new KeymapSetContextAction(JTextComponent.addKeymap(null, null));
                                cur.addActionForKeyStroke(mb.keys[j], sca);
                            }
                            cur = ((KeymapSetContextAction)sca).contextKeymap;
                        }
                    }
                    added = true;
                }
            }
            if (!added) {
                if (bindings[i].key != null) {
                    delegate.addActionForKeyStroke(bindings[i].key, a);
                } else { // key is null -> set default action
                    setDefaultAction(a);
                }
            }
        }
    }
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码8 项目: openjdk-jdk9   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码9 项目: jdk8u-jdk   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码10 项目: hottub   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码11 项目: openjdk-8-source   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码12 项目: openjdk-8   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码13 项目: jdk8u_jdk   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码14 项目: jdk8u-jdk   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码15 项目: jdk8u-dev-jdk   文件: bug6474153.java
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
    if (keyActionArray.length != 1) {
        throw new RuntimeException("Wrong array lenght!");
    }
    if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
        throw new RuntimeException("Wrong action name!");
    }
    if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
        throw new RuntimeException("Wrong keystroke!");
    }
}
 
源代码16 项目: nextreports-designer   文件: SyntaxEditorKit.java
protected JTextComponent.KeyBinding[] getKeyBindings() {
	List<JTextComponent.KeyBinding> keyBindings = new ArrayList<JTextComponent.KeyBinding>();
	keyBindings.addAll(Arrays.asList(getDefaultKeyBindings()));
	keyBindings.addAll(Arrays.asList(getCustomKeyBindings()));
	
	return keyBindings.toArray(new JTextComponent.KeyBinding[keyBindings.size()]);
}
 
源代码17 项目: PacketProxy   文件: GUIMain.java
/**
 * JTextPane上でCommand+Cとかでコピペをできるようにする
 */
private void addShortcutForMac() {
	if (!PacketProxyUtility.getInstance().isMac()) {
		return;
	}
	JPanel p = (JPanel) getContentPane();
	InputMap im = p.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
	ActionMap am = p.getActionMap();
	int hotkey = (KeyEvent.CTRL_MASK | KeyEvent.META_MASK);
	registerTabShortcut(KeyEvent.VK_H, hotkey, im, am, Panes.HISTORY.ordinal());
	registerTabShortcut(KeyEvent.VK_I, hotkey, im, am, Panes.INTERCEPT.ordinal());
	registerTabShortcut(KeyEvent.VK_R, hotkey, im, am, Panes.REPEATER.ordinal());
	registerTabShortcut(KeyEvent.VK_B, hotkey, im, am, Panes.BULKSENDER.ordinal());
	registerTabShortcut(KeyEvent.VK_O, hotkey, im, am, Panes.OPTIONS.ordinal());
	registerTabShortcut(KeyEvent.VK_L, hotkey, im, am, Panes.LOG.ordinal());

	JTextComponent.KeyBinding[] bindings1 = {
		new JTextComponent.KeyBinding(
				KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
				DefaultEditorKit.copyAction),
		new JTextComponent.KeyBinding(
				KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
				DefaultEditorKit.pasteAction),
		new JTextComponent.KeyBinding(
				KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
				DefaultEditorKit.cutAction),
		new JTextComponent.KeyBinding(
				KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
				DefaultEditorKit.selectAllAction),
	};

	JTextPane component_tp = new JTextPane();
	Keymap keymap_tp = component_tp.getKeymap();
	JTextComponent.loadKeymap(keymap_tp, bindings1, component_tp.getActions());

	JTextField component_tf = new JTextField();
	Keymap keymap_tf = component_tf.getKeymap();
	JTextComponent.loadKeymap(keymap_tf, bindings1, component_tf.getActions());

	JTextArea component_ta = new JTextArea();
	Keymap keymap_ta = component_ta.getKeymap();
	JTextComponent.loadKeymap(keymap_ta, bindings1, component_ta.getActions());
}
 
源代码18 项目: netbeans   文件: MultiKeyBinding.java
/** Constructor for existing KeyBinding */
public MultiKeyBinding(JTextComponent.KeyBinding kb) {
    this(kb.key, kb.actionName);
}
 
源代码19 项目: nextreports-designer   文件: BaseEditorKit.java
@Override
protected KeyBinding[] getCustomKeyBindings() {
   	return new JTextComponent.KeyBinding[] {
   			new JTextComponent.KeyBinding(KeyStroke.getKeyStroke("control F"), findReplaceAction),
   	};
}
 
源代码20 项目: nextreports-designer   文件: SyntaxEditorKit.java
protected JTextComponent.KeyBinding[] getCustomKeyBindings() {
	return new JTextComponent.KeyBinding[0];
}