@Test public void matchKeyEvent() { KeyInfo keyInfo = new KeyInfo(KeyEvent.VK_UP, KeyEvent.SHIFT_DOWN_MASK, "Shift+Up"); KeyEvent sameCodeDiffMods = createKeyEvent(KeyEvent.VK_UP, KeyEvent.CTRL_DOWN_MASK); KeyEvent sameCodeZeroMods = createKeyEvent(KeyEvent.VK_UP, 0); KeyEvent diffCodeSameMods = createKeyEvent(KeyEvent.VK_DOWN, KeyEvent.SHIFT_DOWN_MASK); KeyEvent sameCodeSameMods = createKeyEvent(KeyEvent.VK_UP, KeyEvent.SHIFT_DOWN_MASK); assertFalse(keyInfo.matchesEvent(sameCodeDiffMods)); assertFalse(keyInfo.matchesEvent(sameCodeZeroMods)); assertFalse(keyInfo.matchesEvent(diffCodeSameMods)); assertTrue(keyInfo.matchesEvent(sameCodeSameMods)); }
public boolean matchesEvent(KeyEvent e) { return e != null && e.getKeyCode() == keyCode && (e.getModifiersEx() ^ modifiers) == 0; }
KeyInfo { public boolean matchesEvent(KeyEvent e) { return e != null && e.getKeyCode() == keyCode && (e.getModifiersEx() ^ modifiers) == 0; } }
KeyInfo { public boolean matchesEvent(KeyEvent e) { return e != null && e.getKeyCode() == keyCode && (e.getModifiersEx() ^ modifiers) == 0; } KeyInfo(int keyCode, int modifiers, String desc);  KeyInfo(KeyInfo keyInfo); }
KeyInfo { public boolean matchesEvent(KeyEvent e) { return e != null && e.getKeyCode() == keyCode && (e.getModifiersEx() ^ modifiers) == 0; } KeyInfo(int keyCode, int modifiers, String desc);  KeyInfo(KeyInfo keyInfo); int getKeyCode(); int getModifiers(); @Override String toString(); boolean matchesEvent(KeyEvent e); @Override boolean equals(Object obj); @Override int hashCode(); }
KeyInfo { public boolean matchesEvent(KeyEvent e) { return e != null && e.getKeyCode() == keyCode && (e.getModifiersEx() ^ modifiers) == 0; } KeyInfo(int keyCode, int modifiers, String desc);  KeyInfo(KeyInfo keyInfo); int getKeyCode(); int getModifiers(); @Override String toString(); boolean matchesEvent(KeyEvent e); @Override boolean equals(Object obj); @Override int hashCode();  }