Java examples for Swing:Key Event
Returns a key stroke with the modifier #getMenuShortcutMask() .
//package com.java2s; import java.awt.Toolkit; import javax.swing.KeyStroke; public class Main { /**/*ww w. j av a2 s.c om*/ * Returns a key stroke with the modifier {@code #getMenuShortcutMask()}. * * @param keyCode key code * @return key stroke */ public static KeyStroke getKeyStrokeMenuShortcut(int keyCode) { return KeyStroke.getKeyStroke(keyCode, getMenuShortcutMask()); } /** * Returns a key stroke without modifiers. * * @param keyCode key code * @return key stroke */ public static KeyStroke getKeyStroke(int keyCode) { return KeyStroke.getKeyStroke(keyCode, 0); } /** * The same as {@code Toolkit#getMenuShortcutKeyMask()}. * * @return mask */ public static int getMenuShortcutMask() { return Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } }