public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
bug6538132.createGui();
}
});
if(isWinLaf) {
ExtendedRobot robot = new ExtendedRobot();
robot.setAutoDelay(10);
robot.waitForIdle();
Point p1 = menu1.getLocationOnScreen();
final int x1 = p1.x + menu1.getWidth() / 2;
final int y1 = p1.y + menu1.getHeight() / 2;
robot.glide(0, 0, x1, y1);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
assertPopupOpen();
Point p2 = menu2.getLocationOnScreen();
final int x2 = p2.x + menu2.getWidth() / 2;
final int y2 = p2.y + menu2.getHeight() / 2;
robot.glide(x1, y1, x2, y2);
assertPopupOpen();
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
assertPopupNotOpen();
robot.glide(x2, y2, x1, y1);
assertPopupNotOpen();
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
assertPopupOpen();
}
}
java类java.awt.event.InputEvent的实例源码
bug6538132.java 文件源码
项目:openjdk-jdk10
阅读 19
收藏 0
点赞 0
评论 0
bug6495920.java 文件源码
项目:jdk8u-jdk
阅读 27
收藏 0
点赞 0
评论 0
public void secondHidePopup() {
Point point = this.panel.getLocation();
SwingUtilities.convertPointToScreen(point, this.panel);
robot.mouseMove(point.x - 1, point.y - 1);
Thread.currentThread().setUncaughtExceptionHandler(this);
robot.mousePress(InputEvent.BUTTON1_MASK); // causes second AssertionError on EDT
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
ADC2Module.java 文件源码
项目:VASSAL-src
阅读 22
收藏 0
点赞 0
评论 0
private void configureStatusFlagButtons() throws IOException {
String imageName;
MassKeyCommand command;
imageName = StateFlag.ATTACK.getStatusIconName();
command = new MassKeyCommand();
insertComponent(command, getMainMap());
command.setAttribute(MassKeyCommand.TOOLTIP, "Clear attacked status");
command.setAttribute(MassKeyCommand.BUTTON_TEXT, "Attacked");
command.setAttribute(MassKeyCommand.HOTKEY, null);
command.setAttribute(MassKeyCommand.ICON, imageName);
command.setAttribute(MassKeyCommand.NAME, "Attacked");
command.setAttribute(MassKeyCommand.KEY_COMMAND, new NamedKeyStroke(KeyStroke.getKeyStroke('A', InputEvent.CTRL_DOWN_MASK)));
command.setAttribute(MassKeyCommand.PROPERTIES_FILTER, "Mark Attacked_Active = true");
command.setAttribute(MassKeyCommand.DECK_COUNT, -1);
command.setAttribute(MassKeyCommand.REPORT_SINGLE, Boolean.TRUE);
command.setAttribute(MassKeyCommand.REPORT_FORMAT, "");
imageName = StateFlag.DEFEND.getStatusIconName();
command = new MassKeyCommand();
insertComponent(command, getMainMap());
command.setAttribute(MassKeyCommand.TOOLTIP, "Clear defended status");
command.setAttribute(MassKeyCommand.BUTTON_TEXT, "Defended");
command.setAttribute(MassKeyCommand.HOTKEY, null);
command.setAttribute(MassKeyCommand.ICON, imageName);
command.setAttribute(MassKeyCommand.NAME, "Defended");
command.setAttribute(MassKeyCommand.KEY_COMMAND, new NamedKeyStroke(KeyStroke.getKeyStroke('D', InputEvent.CTRL_DOWN_MASK)));
command.setAttribute(MassKeyCommand.PROPERTIES_FILTER, "Mark Defended_Active = true");
command.setAttribute(MassKeyCommand.DECK_COUNT, -1);
command.setAttribute(MassKeyCommand.REPORT_SINGLE, Boolean.TRUE);
command.setAttribute(MassKeyCommand.REPORT_FORMAT, "");
MultiActionButton button = new MultiActionButton();
insertComponent(button, getMainMap());
button.setAttribute(MultiActionButton.BUTTON_TEXT, "");
button.setAttribute(MultiActionButton.TOOLTIP, "Clear combat status flags.");
button.setAttribute(MultiActionButton.BUTTON_ICON, StateFlag.COMBAT.getStatusIconName());
button.setAttribute(MultiActionButton.BUTTON_HOTKEY, KeyStroke.getKeyStroke('C', InputEvent.CTRL_DOWN_MASK));
button.setAttribute(MultiActionButton.MENU_ITEMS, StringArrayConfigurer.arrayToString(new String[] {"Attacked", "Defended"}));
}
InputEventUtil.java 文件源码
项目:Logisim
阅读 24
收藏 0
点赞 0
评论 0
public static String toString(int mods) {
ArrayList<String> arr = new ArrayList<String>();
if ((mods & InputEvent.CTRL_DOWN_MASK) != 0)
arr.add(CTRL);
if ((mods & InputEvent.ALT_DOWN_MASK) != 0)
arr.add(ALT);
if ((mods & InputEvent.SHIFT_DOWN_MASK) != 0)
arr.add(SHIFT);
if ((mods & InputEvent.BUTTON1_DOWN_MASK) != 0)
arr.add(BUTTON1);
if ((mods & InputEvent.BUTTON2_DOWN_MASK) != 0)
arr.add(BUTTON2);
if ((mods & InputEvent.BUTTON3_DOWN_MASK) != 0)
arr.add(BUTTON3);
Iterator<String> it = arr.iterator();
if (it.hasNext()) {
StringBuilder ret = new StringBuilder();
ret.append(it.next());
while (it.hasNext()) {
ret.append(" ");
ret.append(it.next());
}
return ret.toString();
} else {
return "";
}
}
ETableTest.java 文件源码
项目:incubator-netbeans
阅读 26
收藏 0
点赞 0
评论 0
/**
* Test of processKeyBinding method, of class org.netbeans.swing.etable.ETable.
*/
public void testProcessKeyBinding() {
System.out.println("testProcessKeyBinding");
final boolean []called = new boolean[1];
ETable t = new ETable() {
void updatePreferredWidths() {
super.updatePreferredWidths();
called[0] = true;
}
};
KeyEvent ke = new KeyEvent(t, 0, System.currentTimeMillis(), InputEvent.CTRL_MASK, 0, '+');
t.processKeyBinding(null, ke, 0, true);
assertTrue("update pref size not called", called[0]);
}
PropertySheet.java 文件源码
项目:VASSAL-src
阅读 26
收藏 0
点赞 0
评论 0
/** Changes the "type" definition this decoration, which discards all value data and structures.
* Format: definition; name; keystroke
*/
public void mySetType(String s) {
s = s.substring(ID.length());
SequenceEncoder.Decoder st = new SequenceEncoder.Decoder(s, TYPE_DELIMITOR);
m_definition = st.nextToken();
menuName = st.nextToken();
final String launchKeyToken = st.nextToken("");
commitStyle = st.nextInt(COMMIT_DEFAULT);
String red = st.hasMoreTokens() ? st.nextToken() : "";
String green = st.hasMoreTokens() ? st.nextToken() : "";
String blue = st.hasMoreTokens() ? st.nextToken() : "";
final String launchKeyStrokeToken = st.nextToken("");
backgroundColor = red.equals("") ? null : new Color(atoi(red), atoi(green), atoi(blue));
frame = null;
// Handle conversion from old character only key
if (launchKeyStrokeToken.length() > 0) {
launchKeyStroke = NamedHotKeyConfigurer.decode(launchKeyStrokeToken);
}
else if (launchKeyToken.length() > 0) {
launchKeyStroke = new NamedKeyStroke(launchKeyToken.charAt(0), InputEvent.CTRL_MASK);
}
else {
launchKeyStroke = new NamedKeyStroke('P', InputEvent.CTRL_MASK);
}
}
ActionCut.java 文件源码
项目:jmt
阅读 22
收藏 0
点赞 0
评论 0
/**
* Defines an <code>Action</code> object with a default
* description string and default icon.
*/
public ActionCut(Mediator mediator) {
super("Cut", "Cut", mediator);
putValue(SHORT_DESCRIPTION, "Cut");
putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_T));
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));
setEnabled(false);
}
KeyStrokeUtils.java 文件源码
项目:incubator-netbeans
阅读 21
收藏 0
点赞 0
评论 0
/**
* Convert human-readable keystroke name to {@link KeyStroke} object.
*/
public static @CheckForNull KeyStroke getKeyStroke(
@NonNull String keyStroke) {
int modifiers = 0;
while (true) {
if (keyStroke.startsWith(EMACS_CTRL)) {
modifiers |= InputEvent.CTRL_DOWN_MASK;
keyStroke = keyStroke.substring(EMACS_CTRL.length());
} else if (keyStroke.startsWith(EMACS_ALT)) {
modifiers |= InputEvent.ALT_DOWN_MASK;
keyStroke = keyStroke.substring(EMACS_ALT.length());
} else if (keyStroke.startsWith(EMACS_SHIFT)) {
modifiers |= InputEvent.SHIFT_DOWN_MASK;
keyStroke = keyStroke.substring(EMACS_SHIFT.length());
} else if (keyStroke.startsWith(EMACS_META)) {
modifiers |= InputEvent.META_DOWN_MASK;
keyStroke = keyStroke.substring(EMACS_META.length());
} else if (keyStroke.startsWith(STRING_ALT)) {
modifiers |= InputEvent.ALT_DOWN_MASK;
keyStroke = keyStroke.substring(STRING_ALT.length());
} else if (keyStroke.startsWith(STRING_META)) {
modifiers |= InputEvent.META_DOWN_MASK;
keyStroke = keyStroke.substring(STRING_META.length());
} else {
break;
}
}
KeyStroke ks = Utilities.stringToKey (keyStroke);
if (ks == null) { // Return null to indicate an invalid keystroke
return null;
} else {
KeyStroke result = KeyStroke.getKeyStroke (ks.getKeyCode (), modifiers);
return result;
}
}
ActionPaste.java 文件源码
项目:QN-ACTR-Release
阅读 21
收藏 0
点赞 0
评论 0
/**
* Defines an <code>Action</code> object with a default
* description string and default icon.
*/
public ActionPaste(Mediator mediator) {
super("Paste", "Paste", mediator);
putValue(SHORT_DESCRIPTION, "Paste");
//Conti Andrea
//putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_V));
putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK));
//end
setEnabled(false);
}
DataGroupAction.java 文件源码
项目:intellij-randomness
阅读 23
收藏 0
点赞 0
评论 0
@Override
@SuppressWarnings("PMD.ConfusingTernary") // != 0 for binary mask is expected
public final void actionPerformed(final AnActionEvent event) {
super.actionPerformed(event);
if ((event.getModifiers() & (InputEvent.SHIFT_MASK | InputEvent.SHIFT_DOWN_MASK)) != 0) {
getInsertArrayAction().actionPerformed(event);
} else if ((event.getModifiers() & (InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK)) != 0) {
getSettingsAction().actionPerformed(event);
} else {
getInsertAction().actionPerformed(event);
}
}