List of usage examples for java.awt.event KeyEvent VK_ENTER
int VK_ENTER
To view the source code for java.awt.event KeyEvent VK_ENTER.
Click Source Link
From source file:com.cmsoftware.keyron.vista.admin.CambiarClave.java
private void repetirNuevaClaveKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_repetirNuevaClaveKeyTyped repetirNuevaClave.setBackground(new Color(255, 255, 255)); if (KeyEvent.VK_ENTER == evt.getKeyChar()) { actualizarClave();/* w w w. j a va2 s. c o m*/ } else { labelError.setText(""); } }
From source file:uk.ac.liverpool.narrative.SolutionGraph.java
/** * @param template/*from w w w .j av a 2 s. com*/ * @param out * @param in * @param current * @return * @throws IOException */ private StringBuilder mainLoop(final Template template, final JTextArea out, final JTextField in, STRIPSState current) throws IOException { Collection<Action> aa = ggraph.getOutEdges(current); StringBuilder ssf = new StringBuilder(); if (aa == null) { out.append("No action from the start?\n"); return ssf; } do { if (aa.size() == 1) { Action a = aa.iterator().next(); out.append(actionToString(template, a)); ssf.append(actionToString(template, a)); if (a != null) { current = ggraph.getOpposite(current, a); } } else if (aa.size() > 1) { int n = 0; final Map<Integer, Action> hm = new MapWrapper<Integer, Action>(); out.append(" Please select the next action: " + "\n"); Iterator<Action> it = aa.iterator(); while (it.hasNext()) { n++; Action a = it.next(); out.append(" " + n + ") " + actionToString(template, a)); hm.put(n, a); } out.append("" + "\n"); final STRIPSState c2 = current; in.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_ENTER) return; int a = 0; String s = in.getText(); try { a = Integer.parseInt(s); } catch (Exception x) { } try { a = Integer.parseInt(s); Action a2 = hm.get(a); if (a2 != null) { out.append(actionToString(template, a2)); in.removeKeyListener(this); in.setText(""); mainLoop(template, out, in, ggraph.getOpposite(c2, a2)); } } catch (Exception x) { return; } super.keyReleased(e); } }); return ssf; } else { break; } aa = ggraph.getOutEdges(current); } while (aa.size() > 0); out.append("The end"); return ssf; }
From source file:fll.subjective.SubjectiveFrame.java
/** * Set the tab and return behavior for a table. *//* w ww . j a v a 2s. c om*/ private void setupTabReturnBehavior(final JTable table) { final InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); // Have the enter key work the same as the tab key final KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0); final KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); im.put(enter, im.get(tab)); // Override the default tab behavior // Tab to the next editable cell. When no editable cells goto next cell. final Action oldTabAction = table.getActionMap().get(im.get(tab)); final Action tabAction = new AbstractAction() { public void actionPerformed(final ActionEvent e) { if (null != oldTabAction) { oldTabAction.actionPerformed(e); } final JTable table = (JTable) e.getSource(); final int rowCount = table.getRowCount(); final int columnCount = table.getColumnCount(); int row = table.getSelectedRow(); int column = table.getSelectedColumn(); // skip the no show when tabbing while (!table.isCellEditable(row, column) || table.getColumnClass(column) == Boolean.class) { column += 1; if (column == columnCount) { column = 0; row += 1; } if (row == rowCount) { row = 0; } // Back to where we started, get out. if (row == table.getSelectedRow() && column == table.getSelectedColumn()) { break; } } table.changeSelection(row, column, false, false); } }; table.getActionMap().put(im.get(tab), tabAction); }
From source file:com.sec.ose.osi.ui.frm.login.JPanLogin.java
private JButton getJButtonAdvanced() { if (jButtonAdvanced == null) { jButtonAdvanced = new JButton(); jButtonAdvanced.setText("Advanced.."); jButtonAdvanced.setEnabled(true); //jButtonAdvanced.setFocusable(false); jButtonAdvanced.setPreferredSize(new Dimension(100, 28)); jButtonAdvanced.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { mEventHandler.handle(EventHandler.BTN_ADVANCED); }// w w w . jav a 2 s . c om }); jButtonAdvanced.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { mEventHandler.handle(EventHandler.BTN_ADVANCED); } } }); } return jButtonAdvanced; }
From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java
/** Creator Infomation UI **/ private JTextField getJTextFieldCreatorName() { if (jTextFieldCreatorName == null) { jTextFieldCreatorName = new JTextField(); jTextFieldCreatorName.setPreferredSize(new Dimension(200, 22)); jTextFieldCreatorName.addCaretListener(new javax.swing.event.CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { mEventHandler.handle(EventHandler.CHECK_BLANK); }//from w ww. ja v a2 s .com }); jTextFieldCreatorName.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (jTextFieldCreatorName.getText().length() == 0) { jTextFieldCreatorName.requestFocusInWindow(); } else { getJTextFieldCreatorEmail().requestFocusInWindow(); } } } }); try { User userInfo = ProtexSDKAPIManager.getUserAPI() .getUserByEmail(LoginSessionEnt.getInstance().getUserID()); jTextFieldCreatorName.setText(userInfo.getFirstName() + " " + userInfo.getLastName()); } catch (SdkFault e1) { e1.printStackTrace(); } } return jTextFieldCreatorName; }
From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java
/** * Upload file typing file path directly * @param tempFile/*from ww w. ja v a2 s.c om*/ */ public static void uploadFileUsingKeyboardTyping(File tempFile) { try { Keyboard keyboard = new Keyboard(); Robot robot = keyboard.getRobot(); WaitHelper.waitForSeconds(1); // // Press Enter // robot.keyPress(KeyEvent.VK_ENTER); // // // Release Enter // robot.keyRelease(KeyEvent.VK_ENTER); keyboard.typeKeys(tempFile.getAbsolutePath()); 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 typing keys: " + e.getMessage()); } }
From source file:com.github.fritaly.dualcommander.DirectoryBrowser.java
@Override public void keyPressed(KeyEvent e) { if (e.getSource() != table) { return;//w w w.j av a2s. c o m } if (e.getKeyCode() == KeyEvent.VK_ENTER) { // What's the current selection ? final List<File> selection = getSelection(); if (selection.size() == 1) { final File selectedFile = selection.iterator().next(); if (selectedFile.isDirectory()) { // Change to the selected directory setDirectory(selectedFile); } } } else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { // Return to the parent directory (if any) final File parentDir = getParentDirectory(); if ((parentDir != null) && parentDir.exists()) { setDirectory(parentDir); } } else { // Propagate event to our listeners processKeyEvent(new KeyEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); } }
From source file:org.openmicroscopy.shoola.agents.util.SelectionWizardUI.java
/** Initializes the components composing the display.*/ private void initComponents() { filterAnywhere = true;/*from www . j a va 2 s .co m*/ filterArea = new JTextField(); originalColor = filterArea.getForeground(); setTextFieldDefault(DEFAULT_FILTER_TEXT); StringBuilder builder = new StringBuilder(); builder.append("Filter"); if (TagAnnotationData.class.equals(type)) { builder.append(" Tags."); } else if (FileAnnotationData.class.equals(type)) { builder.append(" Attachments."); } else if (DatasetData.class.equals(type)) { builder.append(" Datasets."); } else builder.append("."); filterArea.setToolTipText(builder.toString()); filterArea.getDocument().addDocumentListener(this); filterArea.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent evt) { String value = filterArea.getText(); if (StringUtils.isBlank(value)) { setTextFieldDefault(DEFAULT_FILTER_TEXT); } } @Override public void focusGained(FocusEvent evt) { } }); filterArea.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { String value = filterArea.getText(); if (DEFAULT_FILTER_TEXT.equals(value)) { setTextFieldDefault(null); } } }); filterArea.addKeyListener(new KeyAdapter() { /** * Adds the items to the selected list. * @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER && filterArea.isFocusOwner()) { addItem(); //reset filter setTextFieldDefault(DEFAULT_FILTER_TEXT); availableItemsListbox.requestFocus(); } } }); sorter = new ViewerSorter(); availableItemsListbox = new JTree(); initializeTree(availableItemsListbox, user); availableItemsListbox.addKeyListener(new KeyAdapter() { /** * Adds the items to the selected list. * @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER && availableItemsListbox.isFocusOwner()) { addItem(); } } }); availableItemsListbox.addMouseListener(new MouseAdapter() { /** * Adds the items to the selected list. * @see MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent e) { if (e.getClickCount() == 2) { if (availableItemsListbox.isFocusOwner()) addItem(); } } }); availableItemsListbox.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent evt) { firePropertyChange(AVAILABLE_SELECTION_CHANGE, Boolean.TRUE, Boolean.FALSE); } }); selectedItemsListbox = new JTree(); initializeTree(selectedItemsListbox, user); selectedItemsListbox.addKeyListener(new KeyAdapter() { /** * Removes the selected elements from the selected list. * @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER && selectedItemsListbox.isFocusOwner()) { removeItem(); } } }); selectedItemsListbox.addMouseListener(new MouseAdapter() { /** * Removes the selected elements from the selected list. * @see MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent e) { if (e.getClickCount() == 2) { if (selectedItemsListbox.isFocusOwner()) removeItem(); } } }); IconManager icons = IconManager.getInstance(); addButton = new JButton(icons.getIcon(IconManager.RIGHT_ARROW)); removeButton = new JButton(icons.getIcon(IconManager.LEFT_ARROW)); addAllButton = new JButton(icons.getIcon(IconManager.DOUBLE_RIGHT_ARROW)); removeAllButton = new JButton(icons.getIcon(IconManager.DOUBLE_LEFT_ARROW)); addButton.setActionCommand("" + ADD); addButton.addActionListener(this); addAllButton.setActionCommand("" + ADD_ALL); addAllButton.addActionListener(this); removeButton.setActionCommand("" + REMOVE); removeButton.addActionListener(this); removeAllButton.setActionCommand("" + REMOVE_ALL); removeAllButton.addActionListener(this); setImmutableElements(null); }
From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java
private JTextField getJTextFieldCreatorEmail() { if (jTextFieldCreatorEmail == null) { jTextFieldCreatorEmail = new JTextField(); jTextFieldCreatorEmail.setPreferredSize(new Dimension(200, 22)); jTextFieldCreatorEmail.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (jTextFieldCreatorEmail.getText().length() == 0) { jTextFieldCreatorEmail.requestFocusInWindow(); } else { getJTextFieldOrganizationName().requestFocusInWindow(); }//from w w w .j ava 2 s .c o m } } }); jTextFieldCreatorEmail.setText(LoginSessionEnt.getInstance().getUserID()); } return jTextFieldCreatorEmail; }
From source file:org.domainmath.gui.MainFrame.java
/** * Set TextArea with octave syntax style. *//*from w w w .ja v a2 s .co m*/ public void setUpArea() { areaFileTab = new RSyntaxTextArea(); areaFileTab.setFont(this.preferencesDlg.getScriptFont()); areaFileTab.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_OCTAVE); scroll1 = new RTextScrollPane(areaFileTab); gutterFileTab = scroll1.getGutter(); gutterFileTab.setVisible(true); gutterFileTab.setBookmarkingEnabled(true); urlDebugImageStop = getClass().getResource("resources/stop.png"); gutterFileTab.setBookmarkIcon(new ImageIcon(urlDebugImageStop)); gutterFileTab.setFoldIndicatorEnabled(true); needOct(true); scroll1.setWheelScrollingEnabled(true); KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, ActionEvent.CTRL_MASK); areaFileTab.getInputMap().put(key, new CtrlEnterAction()); }