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.cmsoftware.keyron.vista.admin.CambiarClave.java

private void claveKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_claveKeyTyped
    clave.setBackground(new Color(255, 255, 255));
    if (KeyEvent.VK_ENTER == evt.getKeyChar()) {
        actualizarClave();/*from w w w . j av a 2s  .c o  m*/
    } else {
        labelError.setText("");
    }
}

From source file:com.sec.ose.osi.ui.frm.login.JPanLogin.java

/**
 * This method initializes jButton1   //from  www .j a va  2 s . c  o  m
 *    
 * @return javax.swing.JButton   
 */
private JButton getJButtonCancel() {
    if (jButtonCancel == null) {
        jButtonCancel = new JButton();
        jButtonCancel.setText("Cancel");
        jButtonCancel.setEnabled(true);
        jButtonCancel.setPreferredSize(new Dimension(100, 28));
        jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                mEventHandler.handle(EventHandler.BTN_CANCEL);
            }
        });
        jButtonCancel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                    mEventHandler.handle(EventHandler.BTN_CANCEL);
                }
            }
        });
    }
    return jButtonCancel;
}

From source file:com.cmsoftware.keyron.vista.Login.java

private void usuarioKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_usuarioKeyTyped
    usuario.setBackground(new Color(255, 255, 255));
    if (KeyEvent.VK_ENTER == evt.getKeyChar()) {
        iniciarSesion();/*from  w w  w  . j ava2s. c o m*/
    } else {
        labelError.setText("");
    }
}

From source file:net.sf.vfsjfilechooser.plaf.metal.MetalVFSFileChooserUI.java

@SuppressWarnings("serial")
@Override//from   www .j  a  v a 2s  .  c  o  m
public void installComponents(VFSJFileChooser fc) {
    AbstractVFSFileSystemView fsv = fc.getFileSystemView();

    fc.setBorder(new EmptyBorder(12, 12, 11, 11));
    fc.setLayout(new BorderLayout(0, 11));

    filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor());
    fc.addPropertyChangeListener(filePane);

    updateUseShellFolder();

    // ********************************* //
    // **** Construct the top panel **** //
    // ********************************* //

    // Directory manipulation buttons
    JPanel topPanel = new JPanel(new BorderLayout(11, 0));
    topButtonPanel = new JPanel();
    topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS));
    topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS);

    // Add the top panel to the fileChooser
    fc.add(topPanel, BorderLayout.NORTH);

    // ComboBox Label
    lookInLabel = new JLabel(lookInLabelText);
    topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS);

    // CurrentDir ComboBox
    directoryComboBox = new JComboBox() {
        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            // Must be small enough to not affect total width.
            d.width = 150;

            return d;
        }
    };
    directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText);
    directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    lookInLabel.setLabelFor(directoryComboBox);
    directoryComboBoxModel = createDirectoryComboBoxModel(fc);
    directoryComboBox.setModel(directoryComboBoxModel);
    directoryComboBox.addActionListener(directoryComboBoxAction);
    directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
    directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT);
    directoryComboBox.setMaximumRowCount(8);

    topPanel.add(directoryComboBox, BorderLayout.CENTER);

    // Up Button
    upFolderButton = new JButton(getChangeToParentDirectoryAction());
    upFolderButton.setText(null);
    upFolderButton.setIcon(upFolderIcon);
    upFolderButton.setToolTipText(upFolderToolTipText);
    upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName);
    upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    upFolderButton.setMargin(shrinkwrap);

    topButtonPanel.add(upFolderButton);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // Home Button
    FileObject homeDir = fsv.getHomeDirectory();
    String toolTipText = homeFolderToolTipText;

    if (fsv.isRoot(homeDir)) {
        toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
    }

    JButton b = new JButton(homeFolderIcon);
    b.setToolTipText(toolTipText);
    b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName);
    b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    b.setMargin(shrinkwrap);

    b.addActionListener(getGoHomeAction());
    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // New Directory Button
    if (!UIManager.getBoolean("FileChooser.readOnly")) {
        b = new JButton(filePane.getNewFolderAction());
        b.setText(null);
        b.setIcon(newFolderIcon);
        b.setToolTipText(newFolderToolTipText);
        b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName);
        b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
        b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
        b.setMargin(shrinkwrap);
    }

    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // View button group
    ButtonGroup viewButtonGroup = new ButtonGroup();

    // List Button
    listViewButton = new JToggleButton(listViewIcon);
    listViewButton.setToolTipText(listViewButtonToolTipText);
    listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName);
    listViewButton.setSelected(true);
    listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    listViewButton.setMargin(shrinkwrap);
    listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST));
    topButtonPanel.add(listViewButton);
    viewButtonGroup.add(listViewButton);

    // Details Button
    detailsViewButton = new JToggleButton(detailsViewIcon);
    detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
    detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
            detailsViewButtonAccessibleName);
    detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    detailsViewButton.setMargin(shrinkwrap);
    detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS));
    topButtonPanel.add(detailsViewButton);
    viewButtonGroup.add(detailsViewButton);
    filePane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            if ("viewType".equals(e.getPropertyName())) {
                final int viewType = filePane.getViewType();

                if (viewType == VFSFilePane.VIEWTYPE_LIST) {
                    listViewButton.setSelected(true);
                } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) {
                    detailsViewButton.setSelected(true);
                }
            }
        }
    });

    // ************************************** //
    // ******* Add the directory pane ******* //
    // ************************************** //
    fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);

    JComponent accessory = fc.getAccessory();

    if (accessory != null) {
        getAccessoryPanel().add(accessory);
    }

    filePane.setPreferredSize(LIST_PREF_SIZE);
    fc.add(filePane, BorderLayout.CENTER);

    // ********************************** //
    // **** Construct the bottom panel ** //
    // ********************************** //
    bottomPanel = getBottomPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
    fc.add(bottomPanel, BorderLayout.SOUTH);

    // FileName label and textfield
    JPanel fileNamePanel = new JPanel();
    fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(fileNamePanel);
    bottomPanel.add(Box.createRigidArea(vstrut5));

    fileNameLabel = new AlignedLabel();
    populateFileNameLabel();
    fileNamePanel.add(fileNameLabel);

    fileNameTextField = new JTextField(35) {
        @Override
        public Dimension getMaximumSize() {
            return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
        }
    };

    PopupHandler.installDefaultMouseListener(fileNameTextField);

    fileNamePanel.add(fileNameTextField);
    fileNameLabel.setLabelFor(fileNameTextField);
    fileNameTextField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            if (!getFileChooser().isMultiSelectionEnabled()) {
                filePane.clearSelection();
            }
        }
    });

    if (fc.isMultiSelectionEnabled()) {
        setFileName(fileNameString(fc.getSelectedFiles()));
    } else {
        setFileName(fileNameString(fc.getSelectedFile()));
    }

    // Filetype label and combobox
    JPanel filesOfTypePanel = new JPanel();
    filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(filesOfTypePanel);

    AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText);
    filesOfTypePanel.add(filesOfTypeLabel);

    filterComboBoxModel = createFilterComboBoxModel();
    fc.addPropertyChangeListener(filterComboBoxModel);
    filterComboBox = new JComboBox(filterComboBoxModel);
    filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText);
    filesOfTypeLabel.setLabelFor(filterComboBox);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    filesOfTypePanel.add(filterComboBox);

    // buttons
    getButtonPanel().setLayout(new ButtonAreaLayout());

    approveButton = new JButton(getApproveButtonText(fc));
    // Note: Metal does not use mnemonics for approve and cancel
    approveButton.addActionListener(getApproveSelectionAction());
    fileNameTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                getApproveSelectionAction().actionPerformed(null);
            }
        }
    });
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    getButtonPanel().add(approveButton);

    cancelButton = new JButton(cancelButtonText);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    cancelButton.addActionListener(getCancelSelectionAction());
    getButtonPanel().add(cancelButton);

    if (fc.getControlButtonsAreShown()) {
        addControlButtons();
    }

    groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
}

From source file:ome.formats.importer.gui.GuiCommonElements.java

/**
 * Fires a button click when using the enter key
 * //from  w w w  .  j av  a 2s  .c  o  m
 * @param button to press when enter is pressed
 */
public static void enterPressesWhenFocused(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:com.cmsoftware.keyron.vista.admin.CambiarClave.java

private void nuevaClaveKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nuevaClaveKeyTyped
    nuevaClave.setBackground(new Color(255, 255, 255));
    if (KeyEvent.VK_ENTER == evt.getKeyChar()) {
        actualizarClave();// w  w  w .  j a v a  2  s. c  o  m
    } else {
        labelError.setText("");
    }
}

From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java

@SuppressWarnings("serial")
@Override/*from w  w w. j a va2 s . co  m*/
public void installComponents(VFSJFileChooser fc) {
    AbstractVFSFileSystemView fsv = fc.getFileSystemView();

    fc.setBorder(new EmptyBorder(12, 12, 11, 11));
    fc.setLayout(new BorderLayout(0, 11));

    filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor());
    fc.addPropertyChangeListener(filePane);

    updateUseShellFolder();

    // ********************************* //
    // **** Construct the top panel **** //
    // ********************************* //

    // Directory manipulation buttons
    JPanel topPanel = new JPanel(new BorderLayout(11, 0));
    topButtonPanel = new JPanel();
    topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS));
    topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS);

    // Add the top panel to the fileChooser
    fc.add(topPanel, BorderLayout.NORTH);

    // ComboBox Label
    lookInLabel = new JLabel(lookInLabelText);
    topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS);

    // CurrentDir ComboBox
    directoryComboBox = new JComboBox() {
        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            // Must be small enough to not affect total width.
            d.width = 150;

            return d;
        }
    };
    directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText);
    directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    lookInLabel.setLabelFor(directoryComboBox);
    directoryComboBoxModel = createDirectoryComboBoxModel(fc);
    directoryComboBox.setModel(directoryComboBoxModel);
    directoryComboBox.addActionListener(directoryComboBoxAction);
    directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
    directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT);
    directoryComboBox.setMaximumRowCount(8);

    topPanel.add(directoryComboBox, BorderLayout.CENTER);

    // Up Button
    upFolderButton = new JButton(getChangeToParentDirectoryAction());
    upFolderButton.setText(null);
    upFolderButton.setIcon(upFolderIcon);
    upFolderButton.setToolTipText(upFolderToolTipText);
    upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName);
    upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    upFolderButton.setMargin(shrinkwrap);

    topButtonPanel.add(upFolderButton);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // Home Button
    FileObject homeDir = fsv.getHomeDirectory();
    String toolTipText = homeFolderToolTipText;

    if (fsv.isRoot(homeDir)) {
        toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
    }

    JButton b = new JButton(homeFolderIcon);
    b.setToolTipText(toolTipText);
    b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName);
    b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    b.setMargin(shrinkwrap);

    b.addActionListener(getGoHomeAction());
    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // New Directory Button
    if (!UIManager.getBoolean("FileChooser.readOnly")) {
        b = new JButton(filePane.getNewFolderAction());
        b.setText(null);
        b.setIcon(newFolderIcon);
        b.setToolTipText(newFolderToolTipText);
        b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName);
        b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
        b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
        b.setMargin(shrinkwrap);
    }

    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // View button group
    ButtonGroup viewButtonGroup = new ButtonGroup();

    // List Button
    listViewButton = new JToggleButton(listViewIcon);
    listViewButton.setToolTipText(listViewButtonToolTipText);
    listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName);
    listViewButton.setSelected(true);
    listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    listViewButton.setMargin(shrinkwrap);
    listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST));
    topButtonPanel.add(listViewButton);
    viewButtonGroup.add(listViewButton);

    // Details Button
    detailsViewButton = new JToggleButton(detailsViewIcon);
    detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
    detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
            detailsViewButtonAccessibleName);
    detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    detailsViewButton.setMargin(shrinkwrap);
    detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS));
    topButtonPanel.add(detailsViewButton);
    viewButtonGroup.add(detailsViewButton);
    filePane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            if ("viewType".equals(e.getPropertyName())) {
                final int viewType = filePane.getViewType();

                if (viewType == VFSFilePane.VIEWTYPE_LIST) {
                    listViewButton.setSelected(true);
                } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) {
                    detailsViewButton.setSelected(true);
                }
            }
        }
    });

    // ************************************** //
    // ******* Add the directory pane ******* //
    // ************************************** //
    fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);

    JComponent accessory = fc.getAccessory();

    if (accessory != null) {
        getAccessoryPanel().add(accessory);
    }

    filePane.setPreferredSize(LIST_PREF_SIZE);
    fc.add(filePane, BorderLayout.CENTER);

    // ********************************** //
    // **** Construct the bottom panel ** //
    // ********************************** //
    bottomPanel = getBottomPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
    fc.add(bottomPanel, BorderLayout.SOUTH);

    // FileName label and textfield
    JPanel fileNamePanel = new JPanel();
    fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(fileNamePanel);
    bottomPanel.add(Box.createRigidArea(vstrut5));

    fileNameLabel = new AlignedLabel();
    populateFileNameLabel();
    fileNamePanel.add(fileNameLabel);

    fileNameTextField = new JTextField(35) {
        @Override
        public Dimension getMaximumSize() {
            return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
        }
    };

    PopupHandler.installDefaultMouseListener(fileNameTextField);

    fileNamePanel.add(fileNameTextField);
    fileNameLabel.setLabelFor(fileNameTextField);
    fileNameTextField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            if (!getFileChooser().isMultiSelectionEnabled()) {
                filePane.clearSelection();
            }
        }
    });

    if (fc.isMultiSelectionEnabled()) {
        setFileName(fileNameString(fc.getSelectedFileObjects()));
    } else {
        setFileName(fileNameString(fc.getSelectedFileObject()));
    }

    // Filetype label and combobox
    JPanel filesOfTypePanel = new JPanel();
    filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(filesOfTypePanel);

    AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText);
    filesOfTypePanel.add(filesOfTypeLabel);

    filterComboBoxModel = createFilterComboBoxModel();
    fc.addPropertyChangeListener(filterComboBoxModel);
    filterComboBox = new JComboBox(filterComboBoxModel);
    filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText);
    filesOfTypeLabel.setLabelFor(filterComboBox);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    filesOfTypePanel.add(filterComboBox);

    // buttons
    getButtonPanel().setLayout(new ButtonAreaLayout());

    approveButton = new JButton(getApproveButtonText(fc));
    // Note: Metal does not use mnemonics for approve and cancel
    approveButton.addActionListener(getApproveSelectionAction());
    fileNameTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                getApproveSelectionAction().actionPerformed(null);
            } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                getFileChooser().cancelSelection();
            }
        }
    });
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    getButtonPanel().add(approveButton);

    cancelButton = new JButton(cancelButtonText);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    cancelButton.addActionListener(getCancelSelectionAction());
    getButtonPanel().add(cancelButton);

    if (fc.getControlButtonsAreShown()) {
        addControlButtons();
    }

    groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
}

From source file:com.cmsoftware.keyron.vista.Login.java

private void claveKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_claveKeyTyped
    clave.setBackground(new Color(255, 255, 255));
    if (KeyEvent.VK_ENTER == evt.getKeyChar()) {
        iniciarSesion();/*  w  ww.j ava  2  s  . c  o  m*/
    } else {
        labelError.setText("");
    }
}

From source file:org.docx4all.swing.text.WordMLEditorKit.java

private void initKeyBindings(JEditorPane editor) {
    ActionMap myActionMap = new ActionMap();
    InputMap myInputMap = new InputMap();

    KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_MASK);
    myActionMap.put(insertSoftBreakAction, new InsertSoftBreakAction(insertSoftBreakAction));
    myInputMap.put(ks, insertSoftBreakAction);

    ks = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    myActionMap.put(enterKeyTypedAction, new EnterKeyTypedAction(enterKeyTypedAction));
    myInputMap.put(ks, enterKeyTypedAction);

    ks = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0);
    myActionMap.put(deleteNextCharAction, new DeleteNextCharAction(deleteNextCharAction));
    myInputMap.put(ks, deleteNextCharAction);

    ks = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0);
    myActionMap.put(deletePrevCharAction, new DeletePrevCharAction(deletePrevCharAction));
    myInputMap.put(ks, deletePrevCharAction);

    myActionMap.setParent(editor.getActionMap());
    myInputMap.setParent(editor.getInputMap());
    editor.setActionMap(myActionMap);//from   w w w  .ja  va2  s .  co m
    editor.setInputMap(JComponent.WHEN_FOCUSED, myInputMap);
}

From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java

/**
 * Use copy to clipboard and copy-paste keyboard shortcut to write something on upload window
 *//*  w w  w  .jav a2s.  c o m*/
public static void uploadFileUsingClipboard(File tempFile) {

    // Copy to clipboard
    Toolkit.getDefaultToolkit().getSystemClipboard()
            .setContents(new StringSelection(tempFile.getAbsolutePath()), null);
    Robot robot;
    try {
        robot = new Robot();

        WaitHelper.waitForSeconds(1);

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

        // Press CTRL+V
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_V);

        // Release CTRL+V
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyRelease(KeyEvent.VK_V);
        WaitHelper.waitForSeconds(1);

        // Press Enter
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);
    } catch (AWTException e) {
        throw new ScenarioException("could not initialize robot to upload file: " + e.getMessage());
    }
}