List of usage examples for java.awt.event KeyEvent VK_V
int VK_V
To view the source code for java.awt.event KeyEvent VK_V.
Click Source Link
From source file:com.all.login.view.NewAccountFormPanel.java
JTextField getEmailTextField() { if (emailTextField == null) { emailTextField = new JTextField(); emailTextField.setBounds(EMAIL_TEXTFIELD_BOUNDS); emailTextField.setSelectionColor(COLOR_SELECTION_TEXTFIELDS); emailTextField.setName(EMAIL_TEXT_FIELD_NAME); final LowercaseFocusListener emailListener = new LowercaseFocusListener(emailTextField, EMAIL_FIELD_NAME);/*from www . java2 s. c o m*/ emailTextField.addFocusListener(emailListener); emailTextField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { int caretPosition = emailTextField.getCaretPosition(); if (emailTextField.getName().startsWith(INVALID_FIELD_NAME)) { emailListener.focusLost(null); } validateAllUserData(); emailTextField.setCaretPosition(caretPosition); } }); InputMap map = emailTextField.getInputMap(JTextField.WHEN_FOCUSED); map.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.VK_CONTROL), null); emailTextField.addKeyListener(new CopyPasteKeyAdapterForMac()); } return emailTextField; }
From source file:edu.harvard.mcz.imagecapture.MainFrame.java
/** * This method initializes jMenuItem2 * /*from ww w.j ava2 s. c o m*/ * @return javax.swing.JMenuItem */ private JMenuItem getJMenuItemPaste() { if (jMenuItemPaste == null) { jMenuItemPaste = new JMenuItem(new DefaultEditorKit.PasteAction()); jMenuItemPaste.setText("Paste"); jMenuItemPaste.setMnemonic(KeyEvent.VK_P); jMenuItemPaste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); jMenuItemPaste.setEnabled(true); } return jMenuItemPaste; }
From source file:com._17od.upm.gui.MainWindow.java
private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); databaseMenu = new JMenu(Translator.translate("databaseMenu")); databaseMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(databaseMenu);// ww w.j a v a 2 s .c o m newDatabaseMenuItem = new JMenuItem(Translator.translate(NEW_DATABASE_TXT), KeyEvent.VK_N); newDatabaseMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); databaseMenu.add(newDatabaseMenuItem); newDatabaseMenuItem.addActionListener(this); newDatabaseMenuItem.setActionCommand(NEW_DATABASE_TXT); openDatabaseMenuItem = new JMenuItem(Translator.translate(OPEN_DATABASE_TXT), KeyEvent.VK_O); openDatabaseMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); databaseMenu.add(openDatabaseMenuItem); openDatabaseMenuItem.addActionListener(this); openDatabaseMenuItem.setActionCommand(OPEN_DATABASE_TXT); openDatabaseFromURLMenuItem = new JMenuItem(Translator.translate(OPEN_DATABASE_FROM_URL_TXT), KeyEvent.VK_L); openDatabaseFromURLMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_L, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); databaseMenu.add(openDatabaseFromURLMenuItem); openDatabaseFromURLMenuItem.addActionListener(this); openDatabaseFromURLMenuItem.setActionCommand(OPEN_DATABASE_FROM_URL_TXT); databaseMenu.addSeparator(); syncWithRemoteDatabaseMenuItem = new JMenuItem(Translator.translate(SYNC_DATABASE_TXT), KeyEvent.VK_S); syncWithRemoteDatabaseMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); databaseMenu.add(syncWithRemoteDatabaseMenuItem); syncWithRemoteDatabaseMenuItem.addActionListener(this); syncWithRemoteDatabaseMenuItem.setEnabled(false); syncWithRemoteDatabaseMenuItem.setActionCommand(SYNC_DATABASE_TXT); changeMasterPasswordMenuItem = new JMenuItem(Translator.translate(CHANGE_MASTER_PASSWORD_TXT), KeyEvent.VK_G); changeMasterPasswordMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); databaseMenu.add(changeMasterPasswordMenuItem); changeMasterPasswordMenuItem.addActionListener(this); changeMasterPasswordMenuItem.setEnabled(false); changeMasterPasswordMenuItem.setActionCommand(CHANGE_MASTER_PASSWORD_TXT); databasePropertiesMenuItem = new JMenuItem(Translator.translate(DATABASE_PROPERTIES_TXT), KeyEvent.VK_I); databasePropertiesMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_I, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); databaseMenu.add(databasePropertiesMenuItem); databasePropertiesMenuItem.addActionListener(this); databasePropertiesMenuItem.setEnabled(false); databasePropertiesMenuItem.setActionCommand(DATABASE_PROPERTIES_TXT); databaseMenu.addSeparator(); exportMenuItem = new JMenuItem(Translator.translate(EXPORT_TXT)); databaseMenu.add(exportMenuItem); exportMenuItem.addActionListener(this); exportMenuItem.setEnabled(false); exportMenuItem.setActionCommand(EXPORT_TXT); importMenuItem = new JMenuItem(Translator.translate(IMPORT_TXT)); databaseMenu.add(importMenuItem); importMenuItem.addActionListener(this); importMenuItem.setEnabled(false); importMenuItem.setActionCommand(IMPORT_TXT); accountMenu = new JMenu(Translator.translate("accountMenu")); accountMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(accountMenu); addAccountMenuItem = new JMenuItem(Translator.translate(ADD_ACCOUNT_TXT), KeyEvent.VK_A); addAccountMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); accountMenu.add(addAccountMenuItem); addAccountMenuItem.addActionListener(this); addAccountMenuItem.setEnabled(false); addAccountMenuItem.setActionCommand(ADD_ACCOUNT_TXT); editAccountMenuItem = new JMenuItem(Translator.translate(EDIT_ACCOUNT_TXT), KeyEvent.VK_E); editAccountMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); accountMenu.add(editAccountMenuItem); editAccountMenuItem.addActionListener(this); editAccountMenuItem.setEnabled(false); editAccountMenuItem.setActionCommand(EDIT_ACCOUNT_TXT); deleteAccountMenuItem = new JMenuItem(Translator.translate(DELETE_ACCOUNT_TXT), KeyEvent.VK_D); deleteAccountMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); accountMenu.add(deleteAccountMenuItem); deleteAccountMenuItem.addActionListener(this); deleteAccountMenuItem.setEnabled(false); deleteAccountMenuItem.setActionCommand(DELETE_ACCOUNT_TXT); viewAccountMenuItem = new JMenuItem(Translator.translate(VIEW_ACCOUNT_TXT), KeyEvent.VK_V); viewAccountMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); accountMenu.add(viewAccountMenuItem); viewAccountMenuItem.addActionListener(this); viewAccountMenuItem.setEnabled(false); viewAccountMenuItem.setActionCommand(VIEW_ACCOUNT_TXT); copyUsernameMenuItem = new JMenuItem(Translator.translate(COPY_USERNAME_TXT), KeyEvent.VK_U); copyUsernameMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); accountMenu.add(copyUsernameMenuItem); copyUsernameMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { copyUsernameToClipboard(); } }); copyUsernameMenuItem.setEnabled(false); copyUsernameMenuItem.setActionCommand(COPY_USERNAME_TXT); copyPasswordMenuItem = new JMenuItem(Translator.translate(COPY_PASSWORD_TXT), KeyEvent.VK_P); copyPasswordMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); accountMenu.add(copyPasswordMenuItem); copyPasswordMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { copyPasswordToClipboard(); } }); copyPasswordMenuItem.setEnabled(false); copyPasswordMenuItem.setActionCommand(COPY_PASSWORD_TXT); launchURLMenuItem = new JMenuItem(Translator.translate(LAUNCH_URL_TXT), KeyEvent.VK_B); launchURLMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_B, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); accountMenu.add(launchURLMenuItem); launchURLMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AccountInformation accInfo = dbActions.getSelectedAccount(); String uRl = accInfo.getUrl(); // Check if the selected url is null or emty and inform the user // via JoptioPane message if ((uRl == null) || (uRl.length() == 0)) { JOptionPane.showMessageDialog(accountMenu.getParent().getParent(), Translator.translate("EmptyUrlJoptionpaneMsg"), Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE); // Check if the selected url is a valid formated url(via // urlIsValid() method) and inform the user via JoptioPane // message } else if (!(urlIsValid(uRl))) { JOptionPane.showMessageDialog(accountMenu.getParent().getParent(), Translator.translate("InvalidUrlJoptionpaneMsg"), Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE); // Call the method LaunchSelectedURL() using the selected // url as input } else { LaunchSelectedURL(uRl); } } }); launchURLMenuItem.setEnabled(false); launchURLMenuItem.setActionCommand(LAUNCH_URL_TXT); exitMenuItem = new JMenuItem(Translator.translate(EXIT_TXT), KeyEvent.VK_X); exitMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); exitMenuItem.addActionListener(this); exitMenuItem.setActionCommand(EXIT_TXT); aboutMenuItem = new JMenuItem(Translator.translate(ABOUT_TXT), KeyEvent.VK_A); aboutMenuItem.addActionListener(this); aboutMenuItem.setActionCommand(ABOUT_TXT); // Because the MAC version of UPM will have a program item in the menu // bar then these items // only need to be added on non-mac platforms if (!PlatformSpecificCode.isMAC()) { databaseMenu.addSeparator(); databaseMenu.add(exitMenuItem); helpMenu = new JMenu(Translator.translate("helpMenu")); helpMenu.setMnemonic(KeyEvent.VK_H); menuBar.add(helpMenu); helpMenu.add(aboutMenuItem); } return menuBar; }
From source file:jchrest.gui.Shell.java
private JMenu createModelMenu(int time) { JMenu menu = new JMenu("Model"); menu.setMnemonic(KeyEvent.VK_M); menu.add(new ClearModelAction(this)); menu.getItem(0).setMnemonic(KeyEvent.VK_C); JMenu submenu = new JMenu("Save"); submenu.setMnemonic(KeyEvent.VK_S); submenu.add(new SaveModelAsVnaAction(this, time)); submenu.getItem(0).setMnemonic(KeyEvent.VK_N); submenu.add(new SaveModelSemanticLinksAsVnaAction(this, time)); submenu.getItem(1).setMnemonic(KeyEvent.VK_L); menu.add(submenu);/*from w ww .jav a 2 s .c o m*/ menu.add(new ModelPropertiesAction(this)); menu.getItem(2).setMnemonic(KeyEvent.VK_P); menu.add(new JSeparator()); menu.add(new ModelInformationAction(this, time)); menu.getItem(4).setMnemonic(KeyEvent.VK_I); menu.add(new ViewModelAction(this)); menu.getItem(5).setMnemonic(KeyEvent.VK_V); return menu; }
From source file:com.netease.dagger.BrowserEmulator.java
/** * javascript executer which must contains one object to be affected * //w w w . j a v a 2 s.c o m * @param js * @param by * */ public void uploadFile(String filepath) { try { //put file path in a clipboard StringSelection strSel = new StringSelection(filepath); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(strSel, null); //imitate mouse event ENTER/COPY/PASTE Robot robot = new Robot(); pause(500); robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); logger.info("Success to upload file: " + filepath); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
@Override public void typeUsingRobot(String locator, String value) { WebElement we = findElement(locator); // try to click otherwise ignore if it fails try {/* www . j a v a2s .co m*/ we.click(); } catch (Exception e) { } ClipboardOwner clipboardOwner = new ClipboardOwner() { @Override public void lostOwnership(Clipboard clipboard, Transferable contents) { } }; Robot robot; try { robot = new Robot(); try { we.sendKeys(value); } catch (Exception e) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); StringSelection stringSelection = new StringSelection(value); clipboard.setContents(stringSelection, clipboardOwner); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_CONTROL); } } catch (AWTException e1) { e1.printStackTrace(); } }
From source file:com.virtusa.isq.rft.runtime.RFTCommandBase.java
/** * Fires a set of java robot key events into the webpage. * // w w w .j a va2 s . c o m * @param commands * the commands * @throws Exception * the exception */ private void fireKeyEvent(final String commands) throws Exception { String[] commandSet = commands.split("\\|"); Robot robot = new Robot(); for (String fullCommand : commandSet) { Utils.pause(retryInterval / 2); int commandIndex = 0; int inputIndex = 1; String command = fullCommand.split("=")[commandIndex]; String input = fullCommand.split("=")[inputIndex]; if ("type".equalsIgnoreCase(command)) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); StringSelection stringSelection = new StringSelection(input); clipboard.setContents(stringSelection, null); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_CONTROL); } else if ("Key".equalsIgnoreCase(command)) { type(input); } else if ("wait".equalsIgnoreCase(command)) { Utils.pause(Integer.parseInt(input)); } else { throw new Exception("Command " + command); } } }
From source file:edu.ku.brc.ui.UIRegistry.java
public JMenu createEditMenu() { JMenu menu = new JMenu(getResourceString("EDIT")); menu.setMnemonic(KeyEvent.VK_E); // Undo and redo are actions of our own creation. undoAction = (UndoAction) makeAction(UndoAction.class, this, "Undo", null, null, new Integer(KeyEvent.VK_Z), KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(UNDO, menu.add(undoAction)); actionMap.put(UNDO, undoAction);/* w ww . j a v a2s . c o m*/ redoAction = (RedoAction) makeAction(RedoAction.class, this, "Redo", null, null, new Integer(KeyEvent.VK_Y), KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(REDO, menu.add(redoAction)); actionMap.put(REDO, redoAction); menu.addSeparator(); // These actions come from the default editor kit. Get the ones we want // and stick them in the menu. Action cutAction = makeAction(DefaultEditorKit.CutAction.class, null, "Cut", null, "Cut selection to clipboard", // I18N ???? new Integer(KeyEvent.VK_X), KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(CUT, menu.add(cutAction)); cutAction.setEnabled(false); actionMap.put(CUT, cutAction); Action copyAction = makeAction(DefaultEditorKit.CopyAction.class, null, "Copy", null, "Copy selection to clipboard", new Integer(KeyEvent.VK_C), KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(COPY, menu.add(copyAction)); copyAction.setEnabled(false); actionMap.put(COPY, copyAction); Action pasteAction = makeAction(DefaultEditorKit.PasteAction.class, null, "Paste", null, "Paste contents of clipboard", new Integer(KeyEvent.VK_V), KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); pasteAction.setEnabled(false); register(PASTE, menu.add(pasteAction)); actionMap.put(PASTE, pasteAction); /* menu.addSeparator(); Action selectAllAction = makeAction(SelectAllAction.class, this, "Select All", null, "Select all text", new Integer(KeyEvent.VK_A), KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu.add(selectAllAction); */ launchFindReplaceAction = (LaunchFindReplaceAction) makeAction(LaunchFindReplaceAction.class, this, "Find", null, null, new Integer(KeyEvent.VK_F), KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); //menu.add(launchFindReplaceAction); // launchFindReplaceAction.setEnabled(false); // register(FIND, menu.add(launchFindReplaceAction)); // actionMap.put(FIND, launchFindReplaceAction); launchFindReplaceAction.setEnabled(false); register(FIND, menu.add(launchFindReplaceAction)); actionMap.put(FIND, launchFindReplaceAction); return menu; }
From source file:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Create the help menu/* w w w . j av a 2 s . co m*/ * * @return The help menu */ private JMenu setupHelpMenu() { final JMenu menu = new JMenu("Help"); menu.setMnemonic(KeyEvent.VK_H); menu.setToolTipText("Menu items related to user assistance"); helpOverviewVideo = new JMenuItem("8 Minute Overview Video"); helpOverviewVideo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.ALT_MASK)); helpOverviewVideo.setMnemonic(KeyEvent.VK_V); helpOverviewVideo.setToolTipText("View an 8 minute overview of Semantic Workbench"); helpOverviewVideo.addActionListener(new OverviewVideoListener()); menu.add(helpOverviewVideo); helpAbout = new JMenuItem("About"); helpAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.ALT_MASK)); helpAbout.setMnemonic(KeyEvent.VK_A); helpAbout.setToolTipText("View version information"); helpAbout.addActionListener(new AboutListener()); menu.add(helpAbout); return menu; }
From source file:com.virtusa.isq.vtaf.runtime.SeleniumTestBase.java
/** * Force handle popup./*ww w . jav a 2 s . c o m*/ * * @param robot * the robot * @param inputString * the input string */ public final void forceHandlePopup(final Robot robot, final String inputString) { String[] commandSet = inputString.split("\\|"); for (String fullCommand : commandSet) { sleep(retryInterval); int commandIndex = 0; int inputIndex = 1; String command = fullCommand.split("=")[commandIndex]; String input = fullCommand.split("=")[inputIndex]; if ("type".equalsIgnoreCase(command)) { StringSelection stringSelection = new StringSelection(input); clipboard.setContents(stringSelection, null); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_CONTROL); } else if ("Key".equalsIgnoreCase(command)) { type(input); } else if ("wait".equalsIgnoreCase(command)) { super.sleep(Integer.parseInt(input)); } } }