java.awt.MenuShortcut Java Examples

The following examples show how to use java.awt.MenuShortcut. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CMenuItem.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    final String finalLabel = label;
    final char finalKeyChar = keyChar;
    final int finalKeyCode = keyCode;
    final int finalKeyMask = keyMask;
    execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
                                  finalKeyCode, finalKeyMask));
}
 
Example #2
Source File: CMenuItem.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask);
}
 
Example #3
Source File: CMenuItem.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask);
}
 
Example #4
Source File: CMenuItem.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    final String finalLabel = label;
    final char finalKeyChar = keyChar;
    final int finalKeyCode = keyCode;
    final int finalKeyMask = keyMask;
    execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
                                  finalKeyCode, finalKeyMask));
}
 
Example #5
Source File: CMenuItem.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask);
}
 
Example #6
Source File: CMenuItem.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask);
}
 
Example #7
Source File: CMenuItem.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask);
}
 
Example #8
Source File: CMenuItem.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    final String finalLabel = label;
    final char finalKeyChar = keyChar;
    final int finalKeyCode = keyCode;
    final int finalKeyMask = keyMask;
    execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
                                  finalKeyCode, finalKeyMask));
}
 
Example #9
Source File: DatabaseManager.java    From evosql with Apache License 2.0 5 votes vote down vote up
void addMenuItems(Menu f, String[] m) {

        for (int i = 0; i < m.length; i++) {
            MenuItem item = new MenuItem(m[i].substring(1));
            char     c    = m[i].charAt(0);

            if (c != '-') {
                item.setShortcut(new MenuShortcut(c));
            }

            item.addActionListener(this);
            f.add(item);
        }
    }
 
Example #10
Source File: CMenuItem.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    final String finalLabel = label;
    final char finalKeyChar = keyChar;
    final int finalKeyCode = keyCode;
    final int finalKeyMask = keyMask;
    execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
                                  finalKeyCode, finalKeyMask));
}
 
Example #11
Source File: CMenuItem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    final String finalLabel = label;
    final char finalKeyChar = keyChar;
    final int finalKeyCode = keyCode;
    final int finalKeyMask = keyMask;
    execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
                                  finalKeyCode, finalKeyMask));
}
 
Example #12
Source File: CMenuItem.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    final String finalLabel = label;
    final char finalKeyChar = keyChar;
    final int finalKeyCode = keyCode;
    final int finalKeyMask = keyMask;
    execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
                                  finalKeyCode, finalKeyMask));
}
 
Example #13
Source File: CMenuItem.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    final String finalLabel = label;
    final char finalKeyChar = keyChar;
    final int finalKeyCode = keyCode;
    final int finalKeyMask = keyMask;
    execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
                                  finalKeyCode, finalKeyMask));
}
 
Example #14
Source File: CMenuItem.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask);
}
 
Example #15
Source File: java_awt_MenuShortcut.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getAnotherObject() {
    return new MenuShortcut(KeyEvent.VK_Z, true);
}
 
Example #16
Source File: java_awt_MenuShortcut.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getObject() {
    return new MenuShortcut(KeyEvent.VK_A);
}
 
Example #17
Source File: java_awt_MenuShortcut.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getAnotherObject() {
    return new MenuShortcut(KeyEvent.VK_Z, true);
}
 
Example #18
Source File: java_awt_MenuShortcut.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getObject() {
    return new MenuShortcut(KeyEvent.VK_A);
}
 
Example #19
Source File: java_awt_MenuShortcut.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getAnotherObject() {
    return new MenuShortcut(KeyEvent.VK_Z, true);
}
 
Example #20
Source File: java_awt_MenuShortcut.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getAnotherObject() {
    return new MenuShortcut(KeyEvent.VK_Z, true);
}
 
Example #21
Source File: java_awt_MenuShortcut.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getObject() {
    return new MenuShortcut(KeyEvent.VK_A);
}
 
Example #22
Source File: java_awt_MenuShortcut.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getAnotherObject() {
    return new MenuShortcut(KeyEvent.VK_Z, true);
}
 
Example #23
Source File: java_awt_MenuShortcut.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getObject() {
    return new MenuShortcut(KeyEvent.VK_A);
}
 
Example #24
Source File: java_awt_MenuShortcut.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getObject() {
    return new MenuShortcut(KeyEvent.VK_A);
}
 
Example #25
Source File: java_awt_MenuShortcut.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getAnotherObject() {
    return new MenuShortcut(KeyEvent.VK_Z, true);
}
 
Example #26
Source File: GUI.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
	private static Menu makeFileMenu() {
		Menu fileMenu = new Menu("File");

		MenuItem openItem = new MenuItem("Open");
		MenuItem saveItem = new MenuItem("Save");
		MenuItem saveAsItem = new MenuItem("Save As");
		MenuItem saveAllItem = new MenuItem("Save All");
		MenuItem closeItem = new MenuItem("Close");
		MenuItem exitItem = new MenuItem("Quit");

		Map<Language, MenuItem> newItems = new THashMap<>();
		for (Language l : Language.values0()) {
			if (l.toString().contains(" ")) {
				continue;
			}
			if (l.toString().contains("EASIK")) {
				continue;
			}
			MenuItem newItem = new MenuItem("New " + l);
			fileMenu.add(newItem);
			newItems.put(l, newItem);
			newItem.addActionListener((ActionEvent e) -> newAction(null, "", l));
		}

		fileMenu.add(openItem);
		// fileMenu.add(openItem2);
		fileMenu.add(saveItem);
		fileMenu.add(saveAsItem);
		fileMenu.add(saveAllItem);
		fileMenu.add(closeItem);
		fileMenu.add(exitItem);

		closeItem.addActionListener(e -> closeAction());
		saveAsItem.addActionListener(e -> saveAsActionAlternate(getSelectedEditor()));

		KeyStroke ctrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
		MenuShortcut s = new MenuShortcut(ctrlS.getKeyCode());
		saveItem.setShortcut(s);

		// TODO aql why doesn't shift mask work? order?
		MenuShortcut sA = new MenuShortcut(ctrlS.getKeyCode(), true);
		saveAllItem.setShortcut(sA);
		saveAllItem.addActionListener(e -> saveAllAction());

		KeyStroke ctrlQ = KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
		MenuShortcut q = new MenuShortcut(ctrlQ.getKeyCode());
		exitItem.setShortcut(q);

		KeyStroke ctrlW = KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
//		KeyStroke commandW = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_DOWN_MASK);
		MenuShortcut c = new MenuShortcut(ctrlW.getKeyCode());
		closeItem.setShortcut(c);

		openItem.addActionListener(e -> openActionAlternate());

		saveItem.addActionListener(e -> saveAction());

		exitItem.addActionListener(e -> exitAction());

		KeyStroke ctrlN = KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
		MenuShortcut n = new MenuShortcut(ctrlN.getKeyCode());
		newItems.get(Language.getDefault()).setShortcut(n);
		KeyStroke ctrlO = KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
		MenuShortcut o = new MenuShortcut(ctrlO.getKeyCode());
		openItem.setShortcut(o);
		return fileMenu;

	}
 
Example #27
Source File: java_awt_MenuShortcut.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getObject() {
    return new MenuShortcut(KeyEvent.VK_A);
}
 
Example #28
Source File: java_awt_MenuShortcut.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getAnotherObject() {
    return new MenuShortcut(KeyEvent.VK_Z, true);
}
 
Example #29
Source File: java_awt_MenuShortcut.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getObject() {
    return new MenuShortcut(KeyEvent.VK_A);
}
 
Example #30
Source File: java_awt_MenuShortcut.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected MenuShortcut getAnotherObject() {
    return new MenuShortcut(KeyEvent.VK_Z, true);
}