Example usage for java.awt.event KeyEvent VK_V

List of usage examples for java.awt.event KeyEvent VK_V

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_V.

Prototype

int VK_V

To view the source code for java.awt.event KeyEvent VK_V.

Click Source Link

Document

Constant for the "V" key.

Usage

From source file:Main.java

/**
 * Returns the mnemonic integer./* w ww.jav  a  2s.  c  o  m*/
 * 
 * @param c The character (uppercase)
 * @return The mnemonic.
 */
@SuppressWarnings("incomplete-switch")
private static int setMnemonicsGet(char c) {
    int mnemonic = 0;
    switch (Character.toUpperCase(c)) {
    case '0':
        mnemonic = KeyEvent.VK_0;
        break;
    case '1':
        mnemonic = KeyEvent.VK_1;
        break;
    case '2':
        mnemonic = KeyEvent.VK_2;
        break;
    case '3':
        mnemonic = KeyEvent.VK_3;
        break;
    case '4':
        mnemonic = KeyEvent.VK_4;
        break;
    case '5':
        mnemonic = KeyEvent.VK_5;
        break;
    case '6':
        mnemonic = KeyEvent.VK_6;
        break;
    case '7':
        mnemonic = KeyEvent.VK_7;
        break;
    case '8':
        mnemonic = KeyEvent.VK_8;
        break;
    case '9':
        mnemonic = KeyEvent.VK_9;
        break;
    case 'A':
        mnemonic = KeyEvent.VK_A;
        break;
    case 'B':
        mnemonic = KeyEvent.VK_B;
        break;
    case 'C':
        mnemonic = KeyEvent.VK_C;
        break;
    case 'D':
        mnemonic = KeyEvent.VK_D;
        break;
    case 'E':
        mnemonic = KeyEvent.VK_E;
        break;
    case 'F':
        mnemonic = KeyEvent.VK_F;
        break;
    case 'G':
        mnemonic = KeyEvent.VK_G;
        break;
    case 'H':
        mnemonic = KeyEvent.VK_H;
        break;
    case 'I':
        mnemonic = KeyEvent.VK_I;
        break;
    case 'J':
        mnemonic = KeyEvent.VK_J;
        break;
    case 'K':
        mnemonic = KeyEvent.VK_K;
        break;
    case 'L':
        mnemonic = KeyEvent.VK_L;
        break;
    case 'M':
        mnemonic = KeyEvent.VK_M;
        break;
    case 'N':
        mnemonic = KeyEvent.VK_N;
        break;
    case 'O':
        mnemonic = KeyEvent.VK_O;
        break;
    case 'P':
        mnemonic = KeyEvent.VK_P;
        break;
    case 'Q':
        mnemonic = KeyEvent.VK_Q;
        break;
    case 'R':
        mnemonic = KeyEvent.VK_R;
        break;
    case 'S':
        mnemonic = KeyEvent.VK_S;
        break;
    case 'T':
        mnemonic = KeyEvent.VK_T;
        break;
    case 'U':
        mnemonic = KeyEvent.VK_U;
        break;
    case 'V':
        mnemonic = KeyEvent.VK_V;
        break;
    case 'W':
        mnemonic = KeyEvent.VK_W;
        break;
    case 'X':
        mnemonic = KeyEvent.VK_X;
        break;
    case 'Y':
        mnemonic = KeyEvent.VK_Y;
        break;
    case 'Z':
        mnemonic = KeyEvent.VK_Z;
        break;
    }
    return mnemonic;
}

From source file:Main.java

/**
 * Returns true if the given event is corrent gesture for
 * accessing clipboard// w  ww.j a v a2s. c om
 *
 * @param ie InputEvent to check
 */

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;
}

From source file:be.fedict.eid.tsl.tool.TslTool.java

private void initFileMenu(JMenuBar menuBar) {
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);/*from  ww w . ja  v a2  s.c  o  m*/

    initNewMenu(fileMenu);

    addActionMenuItem("Open", KeyEvent.VK_O, OPEN_ACTION_COMMAND, fileMenu);
    fileMenu.addSeparator();
    this.signMenuItem = addActionMenuItem("Sign", KeyEvent.VK_S, SIGN_ACTION_COMMAND, fileMenu, false);
    this.saveMenuItem = addActionMenuItem("Save", KeyEvent.VK_A, SAVE_ACTION_COMMAND, fileMenu, false);
    this.saveAsMenuItem = addActionMenuItem("Save As", KeyEvent.VK_V, SAVE_AS_ACTION_COMMAND, fileMenu, false);
    this.exportMenuItem = addActionMenuItem("Export", KeyEvent.VK_E, EXPORT_ACTION_COMMAND, fileMenu, false);
    this.closeMenuItem = addActionMenuItem("Close", KeyEvent.VK_C, CLOSE_ACTION_COMMAND, fileMenu, false);
    fileMenu.addSeparator();
    addActionMenuItem("Exit", KeyEvent.VK_X, EXIT_ACTION_COMMAND, fileMenu);
}

From source file:com.mirth.connect.client.ui.Mirth.java

/**
 * Create the alternate key bindings for the menu shortcut key mask. This is called if the menu
 * shortcut key mask is not the CTRL key (i.e. COMMAND on OSX)
 */// w w w  .  j  av  a  2s .c  o m
private static void createAlternateKeyBindings() {
    int acceleratorKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    // Add the common KeyBindings for macs
    KeyBinding[] defaultBindings = {
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_C, acceleratorKey), DefaultEditorKit.copyAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V, acceleratorKey), DefaultEditorKit.pasteAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_X, acceleratorKey), DefaultEditorKit.cutAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_A, acceleratorKey),
                    DefaultEditorKit.selectAllAction),
            // deleteNextWordAction and deletePrevWordAction were not available in Java 1.5
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, acceleratorKey),
                    DefaultEditorKit.deleteNextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, acceleratorKey),
                    DefaultEditorKit.deletePrevWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, acceleratorKey),
                    DefaultEditorKit.nextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, acceleratorKey),
                    DefaultEditorKit.nextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, acceleratorKey),
                    DefaultEditorKit.previousWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, acceleratorKey),
                    DefaultEditorKit.previousWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionNextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionNextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionPreviousWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionPreviousWordAction) };

    keyMapBindings(new javax.swing.JTextField(), defaultBindings);
    keyMapBindings(new javax.swing.JPasswordField(), defaultBindings);
    keyMapBindings(new javax.swing.JTextPane(), defaultBindings);
    keyMapBindings(new javax.swing.JTextArea(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextField(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthPasswordField(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextPane(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextArea(), defaultBindings);
}

From source file:cz.babi.desktop.remoteme.common.Controller.java

/**
 * Simulate clipboard./*from  w  w w.ja  v  a2 s . c  om*/
 * @param character Character to paste from clipboard.
 */
public void keyClipboard(String addInfo) {
    if (Common.DEBUG)
        LOGGER.debug("[keyClipboard][" + addInfo + "]");

    StringSelection stringSelection = new StringSelection(addInfo);
    clipboard.setContents(stringSelection, clipboardOwner);

    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_V);
    robot.keyRelease(KeyEvent.VK_V);
    robot.keyRelease(KeyEvent.VK_CONTROL);
}

From source file:de.tor.tribes.ui.views.DSWorkbenchDistanceFrame.java

/**
 * Creates new form DSWorkbenchDistanceFrame
 */// www . j a  v  a2s.c om
DSWorkbenchDistanceFrame() {
    initComponents();
    centerPanel = new GenericTestPanel(true);
    jDistancePanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jPanel2);
    unitBox = new JComboBox();
    unitBox.setRenderer(new UnitListCellRenderer());
    unitBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            cellRenderer.setUnit((UnitHolder) unitBox.getSelectedItem());
            jDistanceTable.repaint();
        }
    });
    buildMenu();
    jDistanceTable.setModel(new DistanceTableModel());
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    capabilityInfoPanel1.addActionListener(this);
    jDistanceTable.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DSWorkbenchDistanceFrame.getSingleton()
                    .actionPerformed(new ActionEvent(jDistanceTable, 0, "Delete"));
        }
    }, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jDistanceTable.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DSWorkbenchDistanceFrame.getSingleton()
                    .actionPerformed(new ActionEvent(jDistanceTable, 0, "Paste"));
        }
    }, "Paste", paste, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jDistanceTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //disable find
        }
    });
    jDistanceTable.getSelectionModel().addListSelectionListener(DSWorkbenchDistanceFrame.this);
    cellRenderer.setUnit(UnknownUnit.getSingleton());

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.distance_overview",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
}

From source file:de.tor.tribes.ui.views.DSWorkbenchTagFrame.java

/** Creates new form DSWorkbenchTagFrame */
DSWorkbenchTagFrame() {//from  w  ww .  j  a  va  2  s.  co m
    initComponents();
    centerPanel = new GenericTestPanel();
    jTagPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jTagsPanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this);
    jTagsTable.setModel(new TagTableModel());
    jTagsTable.getSelectionModel().addListSelectionListener(DSWorkbenchTagFrame.this);
    jTagsTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //ignore find
        }
    });

    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    jTagsTable.registerKeyboardAction(DSWorkbenchTagFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jTagsTable.registerKeyboardAction(DSWorkbenchTagFrame.this, "BBCopy", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVillageList.registerKeyboardAction(DSWorkbenchTagFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVillageList.registerKeyboardAction(DSWorkbenchTagFrame.this, "BBCopy_Village", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jTagsTable.registerKeyboardAction(DSWorkbenchTagFrame.this, "Paste", paste,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.tag_view",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>

    initialize();
    pack();
}

From source file:de.tor.tribes.ui.views.DSWorkbenchSelectionFrame.java

/**
 * Creates new form DSWorkbenchSelectionFrame
 *///from   w w w.  j a v a2s  .  c  o  m
DSWorkbenchSelectionFrame() {
    initComponents();
    centerPanel = new GenericTestPanel(true);
    jSelectionPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jSelectionTreePanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this);
    treeData = new LinkedList<>();
    jSelectionTree.setCellRenderer(new NodeCellRenderer());

    KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Copy", copy,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "BBCopy", bbCopy,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Delete", delete,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Paste", paste,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Cut", cut, JComponent.WHEN_FOCUSED);
    jSelectionTree.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //ignore find
        }
    });
    jSelectionTree.getSelectionModel().addTreeSelectionListener(DSWorkbenchSelectionFrame.this);

    buildTree();

    //<editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.selection_tool",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    //</editor-fold>
}

From source file:de.tor.tribes.ui.views.DSWorkbenchDoItYourselfAttackPlaner.java

/**
 * Creates new form DSWorkbenchDoItYourselflAttackPlaner
 *//* www . ja v a2  s  .co  m*/
DSWorkbenchDoItYourselfAttackPlaner() {
    initComponents();

    jAttackTable.setModel(new DoItYourselfAttackTableModel());
    jAttackTable.getSelectionModel().addListSelectionListener(DSWorkbenchDoItYourselfAttackPlaner.this);

    jArriveTime.setDate(Calendar.getInstance().getTime());
    jNewArriveSpinner.setDate(Calendar.getInstance().getTime());
    capabilityInfoPanel1.addActionListener(this);
    KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Copy", copy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Cut", cut,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Paste", paste,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "BBCopy", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //no find
        }
    });

    DoItYourselfCountdownThread thread = new DoItYourselfCountdownThread();
    thread.start();

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.manual_attack_planer",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
    pack();
}

From source file:edu.purdue.cc.bionet.ui.DistributionAnalysisDisplayPanel.java

/**
 * Creates a new DistributionAnalysisDisplayPanel.
 *//*from   www  .  java  2 s.com*/
public DistributionAnalysisDisplayPanel() {
    super(new BorderLayout());
    Language language = Settings.getLanguage();
    this.menuBar = new JMenuBar();
    this.curveFittingMenu = new JMenu(language.get("Curve Fitting"));
    this.curveFittingMenu.setMnemonic(KeyEvent.VK_C);
    this.groupsMenu = new JMenu(language.get("Groups"));
    this.groupsMenu.setMnemonic(KeyEvent.VK_G);
    this.viewMenu = new JMenu(language.get("View"));
    this.viewMenu.setMnemonic(KeyEvent.VK_V);
    this.removeSampleGroupsMenuItem = new JMenuItem(language.get("Reset Sample Groups"), KeyEvent.VK_R);
    this.chooseSampleGroupsMenuItem = new JMenuItem(language.get("Choose Sample Groups"), KeyEvent.VK_C);
    this.fitSelectorPanel = new JPanel(new GridLayout(4, 1));
    this.noFitButton = new JRadioButtonMenuItem(language.get("No Fit"));
    this.robustFitButton = new JRadioButtonMenuItem(language.get("Robust Linear Fit"));
    this.chiSquareFitButton = new JRadioButtonMenuItem(language.get("Chi Square Fit"));
    this.fitButtonGroup = new ButtonGroup();
    this.fitButtonGroup.add(this.noFitButton);
    this.fitButtonGroup.add(this.robustFitButton);
    this.fitButtonGroup.add(this.chiSquareFitButton);
    this.noFitButton.setSelected(true);
    this.hideOutliersViewMenuItem = new JMenuItem(language.get("Hide Current Outliers"));
    this.curveFittingMenu.add(this.noFitButton);
    this.curveFittingMenu.add(this.robustFitButton);
    this.curveFittingMenu.add(this.chiSquareFitButton);
    this.groupsMenu.add(this.removeSampleGroupsMenuItem);
    this.groupsMenu.add(this.chooseSampleGroupsMenuItem);
    this.viewMenu.add(this.hideOutliersViewMenuItem);
    this.chooseSampleGroupsMenuItem.addActionListener(this);
    this.removeSampleGroupsMenuItem.addActionListener(this);
    this.hideOutliersViewMenuItem.addActionListener(this);
    this.add(menuBar, BorderLayout.NORTH);
    this.menuBar.add(this.curveFittingMenu);
    this.menuBar.add(this.groupsMenu);
    this.menuBar.add(this.viewMenu);
}