Java Code Examples for java.awt.event.KeyEvent#VK_X
The following examples show how to use
java.awt.event.KeyEvent#VK_X .
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: OpenTCSDrawingView.java From openAGV with Apache License 2.0 | 6 votes |
@Override public void processKeyEvent(KeyEvent e) { if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) { // Cut, copy, paste and duplicate if (e.getKeyCode() == KeyEvent.VK_X || e.getKeyCode() == KeyEvent.VK_C || e.getKeyCode() == KeyEvent.VK_V || e.getKeyCode() == KeyEvent.VK_D) { if (!appState.hasOperationMode(OperationMode.MODELLING)) { return; } processCutPasteKeyEvent(); } } super.processKeyEvent(e); }
Example 2
Source File: ClipboardKeyAdapter.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
@Override public void keyReleased(KeyEvent event) { if (event.isControlDown() || event.isMetaDown()) { switch (event.getKeyCode()) { case KeyEvent.VK_C: // Copy cancelEditing(); XTableUtils.copyToClipboard(table, false); break; case KeyEvent.VK_X: // Cut cancelEditing(); XTableUtils.copyToClipboard(table, true); break; case KeyEvent.VK_V: // Paste cancelEditing(); XTableUtils.pasteFromClipboard(table); break; default: break; } } }
Example 3
Source File: SwingUtilities2.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Returns true if the given event is corrent gesture for * accessing clipboard * * @param ie InputEvent to check */ @SuppressWarnings("deprecation") private static boolean isAccessClipboardGesture(InputEvent ie) { boolean allowedGesture = false; if (ie instanceof KeyEvent) { //we can validate only keyboard gestures KeyEvent ke = (KeyEvent)ie; int keyCode = ke.getKeyCode(); int keyModifiers = ke.getModifiers(); switch(keyCode) { case KeyEvent.VK_C: case KeyEvent.VK_V: case KeyEvent.VK_X: allowedGesture = (keyModifiers == InputEvent.CTRL_MASK); break; case KeyEvent.VK_INSERT: allowedGesture = (keyModifiers == InputEvent.CTRL_MASK || keyModifiers == InputEvent.SHIFT_MASK); break; case KeyEvent.VK_COPY: case KeyEvent.VK_PASTE: case KeyEvent.VK_CUT: allowedGesture = true; break; case KeyEvent.VK_DELETE: allowedGesture = ( keyModifiers == InputEvent.SHIFT_MASK); break; } } return allowedGesture; }
Example 4
Source File: BoundingBoxWindow.java From Pixie with MIT License | 5 votes |
/** * Handle the keyboard events when Alt key is pressed. * * @param key the key code */ private void handleAltKey(int key) { switch (key) { case KeyEvent.VK_A: // increase left changeSize(-1, 0, 0, 0); break; case KeyEvent.VK_W: // increase top changeSize(0, -1, 0, 0); break; case KeyEvent.VK_D: // increase right changeSize(0, 0, 1, 0); break; case KeyEvent.VK_S: // increase bottom changeSize(0, 0, 0, 1); break; case KeyEvent.VK_Z: // decrease box changeSize(1, 1, -1, -1); break; case KeyEvent.VK_X: // increase box changeSize(-1, -1, 1, 1); break; default: // do nothing break; } }
Example 5
Source File: GUILabelingTool.java From Pixie with MIT License | 5 votes |
/** * Handling of keyboard events when Alt key is pressed. * * @param key the key code */ private void handleAltKey(int key) { switch (key) { case KeyEvent.VK_A: // increase left gc.changeSizeSelection(-1, 0, 0, 0); break; case KeyEvent.VK_W: // increase top gc.changeSizeSelection(0, -1, 0, 0); break; case KeyEvent.VK_D: // increase right gc.changeSizeSelection(0, 0, 1, 0); break; case KeyEvent.VK_S: // increase bottom gc.changeSizeSelection(0, 0, 0, 1); break; case KeyEvent.VK_Z: // decrease box gc.changeSizeSelection(1, 1, -1, -1); break; case KeyEvent.VK_X: // increase box gc.changeSizeSelection(-1, -1, 1, 1); break; default: // do nothing break; } }
Example 6
Source File: ClipboardKeyAdapter.java From gameserver with Apache License 2.0 | 5 votes |
@Override public void keyReleased(KeyEvent event) { if (event.isControlDown()) { if (event.getKeyCode() == KeyEvent.VK_C) { // Copy cancelEditing(); copyToClipboard(false); } else if (event.getKeyCode() == KeyEvent.VK_X) { // Cut cancelEditing(); copyToClipboard(true); } else if (event.getKeyCode() == KeyEvent.VK_V) { // Paste cancelEditing(); pasteFromClipboard(); } } }
Example 7
Source File: PlayerZoneButtonsPanel.java From magarena with GNU General Public License v3.0 | 5 votes |
public static int[] getKeyBindings(MagicPlayerZone aZone) { switch (aZone) { case HAND: return new int[]{KeyEvent.VK_1, KeyEvent.VK_Z, KeyEvent.VK_NUMPAD1}; case GRAVEYARD: return new int[]{KeyEvent.VK_2, KeyEvent.VK_X, KeyEvent.VK_NUMPAD2}; case EXILE: return new int[]{KeyEvent.VK_3, KeyEvent.VK_C, KeyEvent.VK_NUMPAD3}; default: return new int[]{}; } }
Example 8
Source File: Profile.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
@Override public void keyPressed(final KeyEvent ke) { super.keyPressed(ke); if (ke.isConsumed()) return; final int key_code = ke.getKeyCode(); Rectangle box = null; switch(key_code) { case KeyEvent.VK_X: // remove all points if (0 == ke.getModifiers() && (ProjectToolbar.getToolId() == ProjectToolbar.PEN || ProjectToolbar.getToolId() == ProjectToolbar.PENCIL)) { box = getBoundingBox(box); n_points = 0; this.p_i = new double[2][0]; calculateBoundingBox(true); ke.consume(); if (closed) toggleClosed(); updateInDatabase("points"); } break; case KeyEvent.VK_C: // toggle close with shift+c if (0 == (ke.getModifiers() ^ java.awt.Event.SHIFT_MASK)) { //preconditions: at least 2 points! if (n_points > 1) { toggleClosed(); generateInterpolatedPoints(0.05); ke.consume(); } } break; } if (ke.isConsumed()) { Display.repaint(this.layer, box, 5); } }
Example 9
Source File: SwapDefaultsCommand.java From gcs with Mozilla Public License 2.0 | 4 votes |
private SwapDefaultsCommand() { super(I18n.Text("Swap Defaults"), CMD_SWAP_DEFAULTS, KeyEvent.VK_X, Command.SHIFTED_COMMAND_MODIFIER); }
Example 10
Source File: CutCommand.java From gcs with Mozilla Public License 2.0 | 4 votes |
private CutCommand() { super(I18n.Text("Cut"), CMD_CUT, KeyEvent.VK_X); }
Example 11
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 12
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 13
Source File: KeyCodeToChar.java From Repeat with Apache License 2.0 | 4 votes |
private static String getUpperCaseAlphaChar(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 14
Source File: GrammarVizView.java From grammarviz2_src with GNU General Public License v2.0 | 4 votes |
/** * Build the application menu bar. */ private void buildMenuBar() { // Build the File menu. // // JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); fileMenu.getAccessibleContext().setAccessibleDescription("The file menu"); // Open file item JMenuItem openFileItem = new JMenuItem("Select", KeyEvent.VK_O); openFileItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); openFileItem.getAccessibleContext().setAccessibleDescription("Open a data file"); openFileItem.setActionCommand(SELECT_FILE); openFileItem.addActionListener(this); fileMenu.add(openFileItem); // add a separator fileMenu.addSeparator(); // an exit item JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X); exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); exitItem.getAccessibleContext().setAccessibleDescription("Exit from here"); exitItem.addActionListener(this); fileMenu.add(exitItem); // Build the Options menu. // // JMenu settingsMenu = new JMenu("Settings"); settingsMenu.setMnemonic(KeyEvent.VK_S); settingsMenu.getAccessibleContext().setAccessibleDescription("Settings menu"); // an exit item JMenuItem optionsItem = new JMenuItem("GrammarViz options", KeyEvent.VK_P); optionsItem.setActionCommand(OPTIONS_MENU_ITEM); optionsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); optionsItem.getAccessibleContext().setAccessibleDescription("Options"); optionsItem.addActionListener(this); settingsMenu.add(optionsItem); // Build the About menu. JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_F1); helpMenu.getAccessibleContext().setAccessibleDescription("Help & About"); // a help item JMenuItem helpItem = new JMenuItem("Help", KeyEvent.VK_H); helpItem.getAccessibleContext().setAccessibleDescription("Get some help here."); exitItem.addActionListener(controller); helpMenu.add(helpItem); // an about item JMenuItem aboutItem = new JMenuItem("About", KeyEvent.VK_A); aboutItem.getAccessibleContext().setAccessibleDescription("About the app."); aboutItem.setActionCommand(ABOUT_MENU_ITEM); aboutItem.addActionListener(this); helpMenu.add(aboutItem); // make sure that controller is connected with Exit item // exitItem.addActionListener(controller); menuBar.add(fileMenu); menuBar.add(settingsMenu); menuBar.add(helpMenu); }
Example 15
Source File: CutAction.java From PIPE with MIT License | 4 votes |
/** * Constructor * @param applicationController main PIPE application controller */ public CutAction(PipeApplicationController applicationController) { super("Cut", "Cut (Ctrl-X)", KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); this.applicationController = applicationController; }
Example 16
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(); }