Java examples for Swing:Key Event
is to cut KeyEvent
//package com.java2s; import java.awt.Toolkit; import java.awt.event.KeyEvent; public class Main { /**/*from w w w . j a va2 s. c o m*/ * Returns whether to cut, i.e. that the key combination of * {@code #getMenuShortcutMask()} and the character <code>X</code>. * * @param evt key event * @return true if cut */ public static boolean isCut(KeyEvent evt) { if (evt == null) { throw new NullPointerException("evt == null"); } return (evt.getKeyCode() == KeyEvent.VK_X) && (evt.getModifiers() == getMenuShortcutMask()); } /** * The same as {@code Toolkit#getMenuShortcutKeyMask()}. * * @return mask */ public static int getMenuShortcutMask() { return Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } }