Example usage for java.awt.event KeyEvent VK_ENTER

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

Introduction

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

Prototype

int VK_ENTER

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

Click Source Link

Document

Constant for the ENTER virtual key.

Usage

From source file:com.mgmtp.perfload.loadprofiles.ui.util.SwingUtils.java

/**
 * Registers the enter key a {@link JButton}.
 * /*from  ww w  .j a va 2  s.c o  m*/
 * @param button
 *            The button
 */
public static void enterPressesWhenFocused(final JButton button) {
    button.registerKeyboardAction(
            button.getActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false)),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);

    button.registerKeyboardAction(
            button.getActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true)),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true), JComponent.WHEN_FOCUSED);
}

From source file:Main.java

MyTextField(int len) {
    super(len);//from   w w  w .  j  a  v a2s. co  m
    addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent evt) {
            int key = evt.getKeyCode();
            if (key == KeyEvent.VK_ENTER)
                transferFocus();
        }
    });
}

From source file:com.hp.test.framework.jelly.ClickOKonWinDialogTag.java

@Override
public void doTag(XMLOutput arg0) throws MissingAttributeException {
    logger.info("Started Execution of ClickOkonWinDialogTag");
    WebDriver driver = getSelenium();//  w  w  w . ja va2s.  co  m

    try {
        Robot robot = new Robot();

        //Pressky Enter/OK Button
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);

    } catch (AWTException e) {
        logger.error("Exception in the Click OK in Windows dialog" + "\n" + e.getMessage());
    }

    logger.info("Completed Execution of ClickOkonWinDialogTag");
}

From source file:org.suren.autotest.web.framework.awt.AwtKeyboard.java

@Override
public void enter() {
    try {//from   ww  w  .j  a v  a 2 s .c  o  m
        Robot robot = new Robot();
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);
    } catch (AWTException e) {
        e.printStackTrace();
    }
}

From source file:PassiveTextField.java

public void processComponentKeyEvent(KeyEvent evt) {
    switch (evt.getID()) {
    case KeyEvent.KEY_PRESSED:
    case KeyEvent.KEY_RELEASED:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            return;
        }/* www  .  j a v a 2 s. c  o  m*/
        break;

    case KeyEvent.KEY_TYPED:
        if (evt.getKeyChar() == '\r') {
            return;
        }
        break;
    }

    super.processComponentKeyEvent(evt);
}

From source file:com.hp.test.framework.jelly.SelectSaveandOKonDownloadDialogTag.java

@Override
public void doTag(XMLOutput arg0) throws MissingAttributeException {
    logger.info("Started Execution of SelectSaveandOKonDownloadDialogTag");
    WebDriver driver = getSelenium();/*from  w w w. jav a2s.  c o m*/

    try {
        Robot robot = new Robot();

        //Pressky ALT+S
        robot.keyPress(KeyEvent.VK_ALT);
        robot.keyPress(KeyEvent.VK_S);

        //Release ALT
        robot.keyRelease(KeyEvent.VK_ALT);

        //Press Enter
        robot.keyPress(KeyEvent.VK_ENTER);

        //Release Enter
        robot.keyRelease(KeyEvent.VK_ENTER);

    } catch (AWTException e) {
        logger.error("Exception in the Save and Ok on Download dialog" + "\n" + e.getMessage());
    }

    logger.info("Completed Execution of SelectSaveandOKonDownloadDialogTag");
}

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

protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();

    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    rootPane.registerKeyboardAction(new ActionListener() {
        @Override//  w ww.  j a va2 s  . c  o  m
        public void actionPerformed(ActionEvent e) {
            addButtonActionPerformed(null);
        }
    }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    return rootPane;
}

From source file:com.konifar.material_icon_generator.FilterComboBox.java

private void initListener() {
    final JTextField textfield = (JTextField) this.getEditor().getEditorComponent();
    textfield.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent event) {
            switch (event.getKeyCode()) {
            case KeyEvent.VK_ENTER:
            case KeyEvent.VK_ESCAPE:
                requestFocus(false);//from  w  ww  . j a va  2s  .c  om
                break;
            case KeyEvent.VK_UP:
            case KeyEvent.VK_DOWN:
                break;
            default:
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        filter(textfield.getText());
                    }
                });
            }
        }
    });

    getAccessibleContext().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (AccessibleContext.ACCESSIBLE_STATE_PROPERTY.equals(event.getPropertyName())
                    && AccessibleState.FOCUSED.equals(event.getNewValue())
                    && getAccessibleContext().getAccessibleChild(0) instanceof ComboPopup) {
                ComboPopup popup = (ComboPopup) getAccessibleContext().getAccessibleChild(0);
                JList list = popup.getList();

                if (list.getSelectedValue() != null) {
                    setSelectedItem(String.valueOf(list.getSelectedValue()));
                }
            }
        }
    });
}

From source file:com.mirth.connect.client.ui.components.KeyStrokeTextField.java

@Override
public void keyTyped(KeyEvent evt) {
    if (keyCode != null && (evt.getKeyCode() == KeyEvent.VK_ENTER || evt.getKeyCode() == KeyEvent.VK_ESCAPE)) {
        return;/*w  ww  . j  a  va 2 s  . c  o m*/
    }

    // Clear the text field if backspace is pressed
    if (evt.getKeyCode() == KeyEvent.VK_BACK_SPACE || evt.getKeyChar() == '\b') {
        reset();
        PlatformUI.MIRTH_FRAME.setSaveEnabled(true);
    }
    evt.consume();
}

From source file:MiniBrowser.java

public MiniBrowser() {
    setSize(640, 480);//from w w w.  j  a  v a  2  s  . c o m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel buttonPanel = new JPanel();
    backButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            actionBack();
        }
    });
    backButton.setEnabled(false);
    buttonPanel.add(backButton);
    forwardButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            actionForward();
        }
    });
    forwardButton.setEnabled(false);
    buttonPanel.add(forwardButton);
    locationTextField.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                actionGo();
            }
        }
    });
    buttonPanel.add(locationTextField);
    JButton goButton = new JButton("GO");
    goButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            actionGo();
        }
    });
    buttonPanel.add(goButton);
    displayEditorPane.setContentType("text/html");
    displayEditorPane.setEditable(false);
    displayEditorPane.addHyperlinkListener(this);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(buttonPanel, BorderLayout.NORTH);
    getContentPane().add(new JScrollPane(displayEditorPane), BorderLayout.CENTER);
}