Java Code Examples for java.awt.event.KeyEvent#VK_R
The following examples show how to use
java.awt.event.KeyEvent#VK_R .
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: Field.java From JavaRushTasks with MIT License | 6 votes |
@Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case (KeyEvent.VK_LEFT): eventListener.move(Direction.LEFT); break; case (KeyEvent.VK_RIGHT): eventListener.move(Direction.RIGHT); break; case (KeyEvent.VK_UP): eventListener.move(Direction.UP); break; case (KeyEvent.VK_DOWN): eventListener.move(Direction.DOWN); break; case (KeyEvent.VK_R): eventListener.restart(); break; } }
Example 2
Source File: JDA.java From java-disassembler with GNU General Public License v3.0 | 6 votes |
/** * Checks the hotkeys */ public static void checkHotKey(KeyEvent e) { if ((e.getKeyCode() == KeyEvent.VK_O) && isCtrlDown(e)) { openFileChooser(); } else if ((e.getKeyCode() == KeyEvent.VK_N) && isCtrlDown(e)) { JDA.resetWorkSpace(true); } else if ((e.getKeyCode() == KeyEvent.VK_R) && isCtrlDown(e) && isShiftDown(e)) { viewer.reloadResources(); } else if ((e.getKeyCode() == KeyEvent.VK_R) && isCtrlDown(e)) { viewer.refreshView(); } else if ((e.getKeyCode() == KeyEvent.VK_W) && isCtrlDown(e) && isShiftDown(e)) { JDA.closeResources(true); } else if ((e.getKeyCode() == KeyEvent.VK_W) && isCtrlDown(e)) { if (viewer.fileViewerPane.getCurrentViewer() != null) viewer.fileViewerPane.tabs.remove(viewer.fileViewerPane.getCurrentViewer()); } else if ((e.getKeyCode() == KeyEvent.VK_F) && isCtrlDown(e) && isShiftDown(e)) { viewer.doSearchDialog(); } }
Example 3
Source File: CommandDispatcher.java From IBC with GNU General Public License v3.0 | 5 votes |
private void handleReconnectAccountCommand() { JFrame jf = MainWindowManager.mainWindowManager().getMainWindow(); int modifiers = KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK; KeyEvent pressed=new KeyEvent(jf, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), modifiers, KeyEvent.VK_R, KeyEvent.CHAR_UNDEFINED); KeyEvent typed=new KeyEvent(jf, KeyEvent.KEY_TYPED, System.currentTimeMillis(), modifiers, KeyEvent.VK_UNDEFINED, 'R' ); KeyEvent released=new KeyEvent(jf, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), modifiers, KeyEvent.VK_R, KeyEvent.CHAR_UNDEFINED ); jf.dispatchEvent(pressed); jf.dispatchEvent(typed); jf.dispatchEvent(released); mChannel.writeAck(""); }
Example 4
Source File: LayerSet.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
/** If there aren't any tags for keyCode, returns an empty TreeSet. */ @SuppressWarnings("unchecked") public TreeSet<Tag> getTags(final int keyCode) { synchronized (tags) { final HashMap<String,Tag> ts = tags.get(keyCode); return new TreeSet<Tag>(null == ts ? Collections.EMPTY_SET : KeyEvent.VK_R == keyCode ? filterReviewTags(ts.values()) : ts.values()); } }
Example 5
Source File: FunctionPanel.java From opensim-gui with Apache License 2.0 | 5 votes |
public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_CONTROL) { picking = true; } else if (e.getKeyCode() == KeyEvent.VK_I) { zoomPlot(lastMouseX, lastMouseY, true); } else if (e.getKeyCode() == KeyEvent.VK_O) { zoomPlot(lastMouseX, lastMouseY, false); } else if (e.getKeyCode() == KeyEvent.VK_L || e.getKeyCode() == KeyEvent.VK_R || e.getKeyCode() == KeyEvent.VK_U || e.getKeyCode() == KeyEvent.VK_D) { panPlot(e.getKeyCode()); } else if (e.getKeyCode() == KeyEvent.VK_DELETE) { deleteSelectedNodes(); } }
Example 6
Source File: AmidstMenuBuilder.java From amidst with GNU General Public License v3.0 | 5 votes |
private JMenu create_Settings_BiomeProfile() { JMenu result = new JMenu("Biome Profile"); // @formatter:off new BiomeProfileMenuFactory(result, actions, biomeProfileDirectory, "Reload Biome Profiles", KeyEvent.VK_R, MenuShortcuts.RELOAD_BIOME_PROFILES, "Create Example Profile", KeyEvent.VK_C); // @formatter:on return result; }
Example 7
Source File: CommandDispatcher.java From ib-controller with GNU General Public License v3.0 | 5 votes |
private void handleReconnectAccountCommand() { JFrame jf = MainWindowManager.mainWindowManager().getMainWindow(); int modifiers = KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK; KeyEvent pressed=new KeyEvent(jf, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), modifiers, KeyEvent.VK_R, KeyEvent.CHAR_UNDEFINED); KeyEvent typed=new KeyEvent(jf, KeyEvent.KEY_TYPED, System.currentTimeMillis(), modifiers, KeyEvent.VK_UNDEFINED, 'R' ); KeyEvent released=new KeyEvent(jf, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), modifiers, KeyEvent.VK_R, KeyEvent.CHAR_UNDEFINED ); jf.dispatchEvent(pressed); jf.dispatchEvent(typed); jf.dispatchEvent(released); mChannel.writeAck(""); }
Example 8
Source File: ConstructionWizard.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** * Sets the new x and y location and facing of the site * @param c */ public void processKeyRelease(int c) { if (c == KeyEvent.VK_UP // 38 || c == KeyEvent.VK_KP_UP || c == KeyEvent.VK_W || c == KeyEvent.VK_NUMPAD8) { upKeyPressed = false; } else if(c == KeyEvent.VK_DOWN // 40 || c == KeyEvent.VK_KP_DOWN || c == KeyEvent.VK_S || c == KeyEvent.VK_NUMPAD2) { downKeyPressed = false; } else if(c == KeyEvent.VK_LEFT // 37 || c == KeyEvent.VK_KP_LEFT || c == KeyEvent.VK_A || c == KeyEvent.VK_NUMPAD4) { leftKeyPressed = false; } else if(c == KeyEvent.VK_RIGHT // 39 || c == KeyEvent.VK_KP_RIGHT || c == KeyEvent.VK_D || c == KeyEvent.VK_NUMPAD6) { rightKeyPressed = false; } else if(c == KeyEvent.VK_R || c == KeyEvent.VK_F) { turnKeyPressed = false; } }
Example 9
Source File: Polyline.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
@Override public void keyPressed(final KeyEvent ke) { final int keyCode = ke.getKeyCode(); switch (keyCode) { case KeyEvent.VK_D: if (-1 == last_autotrace_start) { if (0 > n_points) Utils.log("Cannot remove last set of autotraced points:\n Manual editions exist, or never autotraced."); return; } // Else, remove: final int len = n_points - last_autotrace_start; n_points = last_autotrace_start; last_autotrace_start = -1; repaint(true, null); // update buckets for layers of all points from n_points to last_autotrace_start final HashSet<Long> hs = new HashSet<Long>(); for (int i = n_points+1; i < n_points+len; i++) hs.add(p_layer[i]); for (final Long l : hs) updateBucket(layer_set.getLayer(l.longValue())); Utils.log("Removed " + len + " autotraced points."); return; case KeyEvent.VK_R: // reset tracing tr_map.remove(layer_set); ke.consume(); Utils.log("Reset tracing data for Polyline " + this); return; } }
Example 10
Source File: AmidstMenuBuilder.java From amidst with GNU General Public License v3.0 | 5 votes |
private JMenu create_Settings_BiomeProfile() { JMenu result = new JMenu("Biome Profile"); // @formatter:off new BiomeProfileMenuFactory(result, actions, biomeProfileDirectory, "Reload Biome Profiles", KeyEvent.VK_R, MenuShortcuts.RELOAD_BIOME_PROFILES, "Create Example Profile", KeyEvent.VK_C); // @formatter:on return result; }
Example 11
Source File: ConstructionWizard.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Sets the new x and y location and facing of the site * @param s * @param c */ public void processKeyPress(ConstructionSite s, int c) { int facing = (int) s.getFacing(); double x = s.getXLocation(); double y = s.getYLocation(); if (c == KeyEvent.VK_UP // 38 || c == KeyEvent.VK_KP_UP || c == KeyEvent.VK_W || c == KeyEvent.VK_NUMPAD8) { upKeyPressed = true; } else if(c == KeyEvent.VK_DOWN // 40 || c == KeyEvent.VK_KP_DOWN || c == KeyEvent.VK_S || c == KeyEvent.VK_NUMPAD2) { downKeyPressed = true; } else if(c == KeyEvent.VK_LEFT // 37 || c == KeyEvent.VK_KP_LEFT || c == KeyEvent.VK_A || c == KeyEvent.VK_NUMPAD4) { leftKeyPressed = true; } else if(c == KeyEvent.VK_RIGHT // 39 || c == KeyEvent.VK_KP_RIGHT || c == KeyEvent.VK_D || c == KeyEvent.VK_NUMPAD6) { rightKeyPressed = true; } else if(c == KeyEvent.VK_R || c == KeyEvent.VK_F) { turnKeyPressed = true; } double w0 = s.getWidth(); double l0 = s.getLength(); double f0 = s.getFacing(); BoundedObject b0 = null; if (upKeyPressed) { b0 = new BoundedObject(s.getXLocation(), s.getYLocation() + 3, w0, l0, f0); if (!isCollided(b0)) s.setYLocation(y + 1); } if (downKeyPressed) { b0 = new BoundedObject(s.getXLocation(), s.getYLocation() - 3, w0, l0, f0); if (!isCollided(b0)) s.setYLocation(y - 1); } if (leftKeyPressed) { b0 = new BoundedObject(s.getXLocation() + 3, s.getYLocation(), w0, l0, f0); if (!isCollided(b0)) s.setXLocation(x + 1); } if (rightKeyPressed) { b0 = new BoundedObject(s.getXLocation() - 3, s.getYLocation(), w0, l0, f0); if (!isCollided(b0)) s.setXLocation(x - 1); } if (turnKeyPressed) { facing = facing + 45; if (facing >= 360) facing = facing - 360; b0 = new BoundedObject(s.getXLocation(), s.getYLocation(), w0, l0, facing); if (!isCollided(b0)) { s.setFacing(facing); } } }
Example 12
Source File: MainFrame.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Creates the file menu. */ private void createFileMenu() { this.fileMenu = new JMenu("File"); // Standard text file menu items. JMenuItem newTextItem = new JMenuItem("New Text...", KeyEvent.VK_N); newTextItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); newTextItem.addActionListener(new NewTextEventHandler(this)); this.fileMenu.add(newTextItem); this.fileMenu.setMnemonic(KeyEvent.VK_F); JMenuItem fileOpen = new JMenuItem("Open Text File", KeyEvent.VK_O); fileOpen.addActionListener(new FileOpenEventHandler(this)); fileOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); this.fileMenu.add(fileOpen); this.fileSaveItem = new JMenuItem("Save Text File", KeyEvent.VK_S); this.fileSaveItem.setEnabled(false); this.fileSaveItem.addActionListener(new FileSaveEventHandler(this)); this.fileSaveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); this.fileMenu.add(this.fileSaveItem); JMenuItem fileSaveAsItem = new JMenuItem("Save Text As...", KeyEvent.VK_A); fileSaveAsItem.addActionListener(new FileSaveAsEventHandler(this)); this.fileMenu.add(fileSaveAsItem); createCPMenu(); this.cpMenu.setMnemonic(KeyEvent.VK_P); this.fileMenu.add(this.cpMenu); this.fileMenu.addSeparator(); this.recentTextFileMenu = new JMenu("Recently used ..."); this.recentTextFileMenu.setMnemonic(KeyEvent.VK_U); this.fileMenu.add(this.recentTextFileMenu); this.fileMenu.addSeparator(); // Color preferences JMenuItem colorPrefsOpenItem = new JMenuItem("Load Color Settings", KeyEvent.VK_L); colorPrefsOpenItem.addActionListener(new ColorPrefsOpenHandler(this)); this.fileMenu.add(colorPrefsOpenItem); JMenuItem colorPrefsSaveItem = new JMenuItem("Save Color Settings", KeyEvent.VK_C); colorPrefsSaveItem.addActionListener(new ColorPrefsSaveHandler(this)); this.fileMenu.add(colorPrefsSaveItem); this.fileMenu.addSeparator(); // Reading and writing type system files. this.typeSystemReadItem = new JMenuItem("Read Type System File"); this.typeSystemReadItem.setEnabled(true); this.typeSystemReadItem.addActionListener(new TypeSystemFileOpenEventHandler(this)); this.fileMenu.add(this.typeSystemReadItem); this.typeSystemWriteItem = new JMenuItem("Write Type System File"); this.typeSystemWriteItem.addActionListener(new XCASSaveTSHandler(this)); this.fileMenu.add(this.typeSystemWriteItem); this.fileMenu.addSeparator(); // Reading and writing XMI CAS files. this.xmiCasReadItem = new JMenuItem("Read XMI CAS File"); this.xmiCasReadItem.addActionListener(new XmiCasFileOpenHandler(this)); this.fileMenu.add(this.xmiCasReadItem); this.xmiCasWriteItem = new JMenuItem("Write XMI CAS File"); this.xmiCasWriteItem.addActionListener(new XmiCasSaveHandler(this)); this.fileMenu.add(this.xmiCasWriteItem); this.fileMenu.addSeparator(); // Reading and writing old-style XCAS files. this.xcasReadItem = new JMenuItem("Read XCAS File", KeyEvent.VK_R); this.xcasReadItem.addActionListener(new XCASFileOpenEventHandler(this)); this.fileMenu.add(this.xcasReadItem); this.xcasWriteItem = new JMenuItem("Write XCAS File", KeyEvent.VK_W); this.xcasWriteItem.addActionListener(new XCASSaveHandler(this)); this.fileMenu.add(this.xcasWriteItem); this.fileMenu.addSeparator(); JMenuItem exit = new JMenuItem("Exit", KeyEvent.VK_X); exit.addActionListener(new SystemExitHandler(this)); this.fileMenu.add(exit); // Disable menu items that can't be executed yet. this.typeSystemWriteItem.setEnabled(false); setEnableCasFileReadingAndWriting(); }
Example 13
Source File: SpecifyRateParameterAction.java From PIPE with MIT License | 4 votes |
public SpecifyRateParameterAction(PipeApplicationController pipeApplicationController) { super("Rate Parameter", "Specify Rate Parameters (alt-R)", KeyEvent.VK_R, InputEvent.ALT_DOWN_MASK); this.pipeApplicationController = pipeApplicationController; }
Example 14
Source File: Commander.java From Scripts with GNU General Public License v3.0 | 4 votes |
@Override public void keyPressed(final KeyEvent ke) { final int key = ke.getKeyCode(); final Object source = ke.getSource(); final boolean meta = (ke.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0; final boolean metaShift = meta && ke.isShiftDown(); // Close if Esc, Ctrl+W or Cmd+W if (key == KeyEvent.VK_ESCAPE || (key == KeyEvent.VK_W && meta)) { quit(); // Trigger Menu accelerators } else if (metaShift) { if (key == KeyEvent.VK_C) // Enter/Exit Console toggleConsoleMode(); else if (key == KeyEvent.VK_G) // Go To... changeDirectory(""); else if (!isConsoleMode() && key == KeyEvent.VK_R) // Reveal Path Utils.revealFile(path); } else if (meta) { if (key == KeyEvent.VK_L) { prompt.requestFocusInWindow(); prompt.selectAll(); } else if (key == KeyEvent.VK_B) { activateTable(); } else if (key == KeyEvent.VK_COMMA) { showOptionsDialog(); } else if (key == KeyEvent.VK_S) { saveQuery(); } else if (!isConsoleMode() && key == KeyEvent.VK_D) { addBookmark(); } else if (!isConsoleMode() && key == KeyEvent.VK_P) { printList(); } else if (!isConsoleMode() && key == KeyEvent.VK_R) { resetFileList("Contents reloaded..."); } } else if (source == prompt) { // Up or down arrows pressed in prompt: Move the focus to list if (key == KeyEvent.VK_UP || key == KeyEvent.VK_DOWN) { activateTable(); } } else if (source == table) { // Focus in list and left arrow key: move up in directory hierarchy if (key == KeyEvent.VK_LEFT) { selectParentDirectory(path); setSelectedItem(table.getSelectedRow()); // Focus in list and right arrow key: List sub-directory } else if (key == KeyEvent.VK_RIGHT) { setSelectedItem(table.getSelectedRow()); if (isFolder(selectedItem)) selectSubDirectory(selectedItem); // Focus in list and enter: Open selected item } else if (key == KeyEvent.VK_ENTER) { ke.consume(); setSelectedItem(table.getSelectedRow()); openItem(selectedItem); // Focus in list and backspace: Switch focus back to prompt } else if (key == KeyEvent.VK_BACK_SPACE) { prompt.requestFocusInWindow(); prompt.selectAll(); // Focus in list and up/down arrow key: Loop through list } else if (key == KeyEvent.VK_UP) { if (table.getSelectedRow() == 0) table.setRowSelectionInterval(tableModel.getRowCount() - 1, tableModel.getRowCount() - 1); } else if (key == KeyEvent.VK_DOWN) { if (table.getSelectedRow() == tableModel.getRowCount() - 1) table.setRowSelectionInterval(0, 0); } } }
Example 15
Source File: PlotFrame.java From OpenDA with GNU Lesser General Public License v3.0 | 4 votes |
/** Construct a plot frame with the specified title and the specified * instance of PlotBox. After constructing this, it is necessary * to call setVisible(true) to make the plot appear. * @param title The title to put on the window. * @param plotArg the plot object to put in the frame, or null to create * an instance of Plot. */ public PlotFrame(String title, PlotBox plotArg) { super(title); if (plotArg == null) { plot = new Plot(); } else { plot = plotArg; } // Background color is a light grey. plot.setBackground(new Color(0xe5e5e5)); _fileMenu.setMnemonic(KeyEvent.VK_F); _editMenu.setMnemonic(KeyEvent.VK_E); _specialMenu.setMnemonic(KeyEvent.VK_S); // File menu JMenuItem[] fileMenuItems = { new JMenuItem("Open", KeyEvent.VK_O), new JMenuItem("Save", KeyEvent.VK_S), new JMenuItem("Save as....", KeyEvent.VK_A), new JMenuItem("Export", KeyEvent.VK_E), new JMenuItem("Print", KeyEvent.VK_P), new JMenuItem("Close", KeyEvent.VK_C), }; // Open button = ctrl-o. fileMenuItems[0].setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK)); // Save button = ctrl-s. fileMenuItems[1].setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)); // Print button = ctrl-p. fileMenuItems[4].setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK)); // Close button = ctrl-w. fileMenuItems[5].setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, Event.CTRL_MASK)); FileMenuListener fml = new FileMenuListener(); // Set the action command and listener for each menu item. for (int i = 0; i < fileMenuItems.length; i++) { fileMenuItems[i].setActionCommand(fileMenuItems[i].getText()); fileMenuItems[i].addActionListener(fml); _fileMenu.add(fileMenuItems[i]); } _menubar.add(_fileMenu); // Edit menu JMenuItem format = new JMenuItem("Format", KeyEvent.VK_F); FormatListener formatListener = new FormatListener(); format.addActionListener(formatListener); _editMenu.add(format); _menubar.add(_editMenu); // Special menu JMenuItem[] specialMenuItems = { new JMenuItem("About", KeyEvent.VK_A), new JMenuItem("Help", KeyEvent.VK_H), new JMenuItem("Clear", KeyEvent.VK_C), new JMenuItem("Fill", KeyEvent.VK_F), new JMenuItem("Reset axes", KeyEvent.VK_R), new JMenuItem("Sample plot", KeyEvent.VK_S), }; SpecialMenuListener sml = new SpecialMenuListener(); // Set the action command and listener for each menu item. for (int i = 0; i < specialMenuItems.length; i++) { specialMenuItems[i].setActionCommand( specialMenuItems[i].getText()); specialMenuItems[i].addActionListener(sml); _specialMenu.add(specialMenuItems[i]); } _menubar.add(_specialMenu); setJMenuBar(_menubar); getContentPane().add(plot, BorderLayout.CENTER); // FIXME: This should not be hardwired in here. setSize(500, 300); // Center. Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); int x = (screenSize.width - frameSize.width) / 2; int y = (screenSize.height - frameSize.height) / 2; setLocation(x, y); }
Example 16
Source File: MainFrame.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Creates the run menu. * * @return the j menu */ private JMenu createRunMenu() { JMenu runMenu = new JMenu("Run"); runMenu.setMnemonic(KeyEvent.VK_R); JMenuItem runMenuItem = new JMenuItem("Load AE", KeyEvent.VK_L); runMenuItem.addActionListener(new AnnotatorOpenEventHandler(this)); runMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.CTRL_MASK)); runMenu.add(runMenuItem); this.reRunMenu = new JMenuItem("Run AE", KeyEvent.VK_R); this.reRunMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK)); runMenu.add(this.reRunMenu); this.reRunMenu.addActionListener(new AnnotatorRerunEventHandler(this)); this.reRunMenu.setEnabled(false); this.runOnCasMenuItem = new JMenuItem("Run AE on CAS", KeyEvent.VK_Y); this.runOnCasMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, ActionEvent.CTRL_MASK)); runMenu.add(this.runOnCasMenuItem); this.runOnCasMenuItem.addActionListener(new AnnotatorRunOnCasEventHandler(this)); this.runOnCasMenuItem.setEnabled(false); this.runCPCMenu = new JMenuItem("Run collectionProcessComplete"); runMenu.add(this.runCPCMenu); this.runCPCMenu.addActionListener(new AnnotatorRunCPCEventHandler(this)); this.runCPCMenu.setEnabled(false); this.showPerfReportItem = new JMenuItem("Performance report"); this.showPerfReportItem.setEnabled(false); this.showPerfReportItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (MainFrame.this.lastRunProcessTrace == null) { MainFrame.this.showError("No performance report to show."); } else { PerformanceReportDialog prd = new PerformanceReportDialog(MainFrame.this); prd.displayStats(MainFrame.this.lastRunProcessTrace, 1, "Process trace"); } } }); runMenu.add(this.showPerfReportItem); runMenu.addSeparator(); this.recentDescFileMenu = new JMenu("Recently used ..."); this.recentDescFileMenu.setMnemonic(KeyEvent.VK_U); runMenu.add(this.recentDescFileMenu); runMenu.addSeparator(); createLangMenu(); runMenu.add(this.langMenu); this.langMenu.setMnemonic(KeyEvent.VK_L); // runMenu.addSeparator(); JMenuItem dataPathItem = new JMenuItem("Set data path"); dataPathItem.addActionListener(new SetDataPathHandler(this)); dataPathItem.setMnemonic(KeyEvent.VK_S); runMenu.addSeparator(); runMenu.add(dataPathItem); return runMenu; }
Example 17
Source File: KeyCodeToChar.java From Repeat with Apache License 2.0 | 4 votes |
private static String getLowerCaseAlphaChar(int code) { switch (code) { case KeyEvent.VK_Q: return "q"; case KeyEvent.VK_W: return "w"; case KeyEvent.VK_E: return "e"; case KeyEvent.VK_R: return "r"; case KeyEvent.VK_T: return "t"; case KeyEvent.VK_Y: return "y"; case KeyEvent.VK_U: return "u"; case KeyEvent.VK_I: return "i"; case KeyEvent.VK_O: return "o"; case KeyEvent.VK_P: return "p"; case KeyEvent.VK_A: return "a"; case KeyEvent.VK_S: return "s"; case KeyEvent.VK_D: return "d"; case KeyEvent.VK_F: return "f"; case KeyEvent.VK_G: return "g"; case KeyEvent.VK_H: return "h"; case KeyEvent.VK_J: return "j"; case KeyEvent.VK_K: return "k"; case KeyEvent.VK_L: return "l"; case KeyEvent.VK_Z: return "z"; case KeyEvent.VK_X: return "x"; case KeyEvent.VK_C: return "c"; case KeyEvent.VK_V: return "v"; case KeyEvent.VK_B: return "b"; case KeyEvent.VK_N: return "n"; case KeyEvent.VK_M: return "m"; default: return ""; } }
Example 18
Source File: Robot.java From xnx3 with Apache License 2.0 | 4 votes |
/** * 将字符型转换为按键码,可直接使用 {@link #press(int)}调用 * @param key 字符型文字,包含 0~9 a~z . * @return 按键码 */ public int StringToKey(String key){ switch (key) { case "a": return KeyEvent.VK_A; case "b": return KeyEvent.VK_B; case "c": return KeyEvent.VK_C; case "d": return KeyEvent.VK_D; case "e": return KeyEvent.VK_E; case "f": return KeyEvent.VK_F; case "g": return KeyEvent.VK_G; case "h": return KeyEvent.VK_H; case "i": return KeyEvent.VK_I; case "j": return KeyEvent.VK_J; case "k": return KeyEvent.VK_K; case "l": return KeyEvent.VK_L; case "m": return KeyEvent.VK_M; case "n": return KeyEvent.VK_N; case "o": return KeyEvent.VK_O; case "p": return KeyEvent.VK_P; case "q": return KeyEvent.VK_Q; case "r": return KeyEvent.VK_R; case "s": return KeyEvent.VK_S; case "t": return KeyEvent.VK_T; case "u": return KeyEvent.VK_U; case "v": return KeyEvent.VK_V; case "w": return KeyEvent.VK_W; case "x": return KeyEvent.VK_X; case "y": return KeyEvent.VK_Y; case "z": return KeyEvent.VK_Z; case "0": return KeyEvent.VK_0; case "1": return KeyEvent.VK_1; case "2": return KeyEvent.VK_2; case "3": return KeyEvent.VK_3; case "4": return KeyEvent.VK_4; case "5": return KeyEvent.VK_5; case "6": return KeyEvent.VK_6; case "7": return KeyEvent.VK_7; case "8": return KeyEvent.VK_8; case "9": return KeyEvent.VK_9; case ".": return KeyEvent.VK_PERIOD; default: break; } return 0; }
Example 19
Source File: ReadArcConnectionTool.java From workcraft with MIT License | 4 votes |
@Override public int getHotKeyCode() { return KeyEvent.VK_R; }
Example 20
Source File: PlotFrame.java From opt4j with MIT License | 4 votes |
/** * Construct a plot frame with the specified title and the specified * instance of PlotBox. After constructing this, it is necessary to call * setVisible(true) to make the plot appear. * * @param title * The title to put on the window. * @param plotArg * the plot object to put in the frame, or null to create an * instance of Plot. */ public PlotFrame(String title, PlotBox plotArg) { super(title); // The Java look & feel is pretty lame, so we use the native // look and feel of the platform we are running on. try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { // Ignore exceptions, which only result in the wrong look and feel. } if (plotArg == null) { plot = new Plot(); } else { plot = plotArg; } // Background color is a light grey. plot.setBackground(new Color(0xe5e5e5)); _fileMenu.setMnemonic(KeyEvent.VK_F); _editMenu.setMnemonic(KeyEvent.VK_E); _specialMenu.setMnemonic(KeyEvent.VK_S); // File menu JMenuItem[] fileMenuItems = { new JMenuItem("Open", KeyEvent.VK_O), new JMenuItem("Save", KeyEvent.VK_S), new JMenuItem("SaveAs", KeyEvent.VK_A), new JMenuItem("Export", KeyEvent.VK_E), new JMenuItem("Print", KeyEvent.VK_P), new JMenuItem("Close", KeyEvent.VK_C), }; // Open button = ctrl-o. fileMenuItems[0].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK)); // Save button = ctrl-s. fileMenuItems[1].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)); // Print button = ctrl-p. fileMenuItems[4].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK)); // Close button = ctrl-w. fileMenuItems[5].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, Event.CTRL_MASK)); FileMenuListener fml = new FileMenuListener(); // Set the action command and listener for each menu item. for (int i = 0; i < fileMenuItems.length; i++) { fileMenuItems[i].setActionCommand(fileMenuItems[i].getText()); fileMenuItems[i].addActionListener(fml); _fileMenu.add(fileMenuItems[i]); } _menubar.add(_fileMenu); // Edit menu JMenuItem format = new JMenuItem("Format", KeyEvent.VK_F); FormatListener formatListener = new FormatListener(); format.addActionListener(formatListener); _editMenu.add(format); _menubar.add(_editMenu); // Special menu JMenuItem[] specialMenuItems = { new JMenuItem("About", KeyEvent.VK_A), new JMenuItem("Help", KeyEvent.VK_H), new JMenuItem("Clear", KeyEvent.VK_C), new JMenuItem("Fill", KeyEvent.VK_F), new JMenuItem("Reset axes", KeyEvent.VK_R), new JMenuItem("Sample plot", KeyEvent.VK_S), }; SpecialMenuListener sml = new SpecialMenuListener(); // Set the action command and listener for each menu item. for (int i = 0; i < specialMenuItems.length; i++) { specialMenuItems[i].setActionCommand(specialMenuItems[i].getText()); specialMenuItems[i].addActionListener(sml); _specialMenu.add(specialMenuItems[i]); } _menubar.add(_specialMenu); setJMenuBar(_menubar); getContentPane().add(plot, BorderLayout.CENTER); // FIXME: This should not be hardwired in here. setSize(500, 300); // Center. Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); int x = (screenSize.width - frameSize.width) / 2; int y = (screenSize.height - frameSize.height) / 2; setLocation(x, y); }