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:zxmax.tools.timerreview.gui.StartTimerWindow.java
private Component getPnlNewTimer() { setTitle(I18N.getLabel(getClass(), "window.title")); JPanel pnlNewTimer = new JPanel(); LayoutManager layout = new MigLayout("flowy", "[328.00][grow,fill]", "[][][][][]"); taFocusOn = new JTextArea(); taFocusOn.setWrapStyleWord(true);/*w ww . j a va 2 s.c o m*/ JScrollPane spFocusOn = new JScrollPane(); tfTitle = new JTextField(30); JButton btnStart = new JButton(); pnlNewTimer.setLayout(layout); btnStart.setText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_BTN_START_LABEL)); taFocusOn.setColumns(20); taFocusOn.setForeground(new Color(0, 153, 0)); taFocusOn.setRows(5); taFocusOn.setTabSize(2); taFocusOn.setText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_TEXT_AREA_TEXT)); taFocusOn.setToolTipText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_TEXT_AREA_TOOL_TIP)); spFocusOn.setViewportView(taFocusOn); taFocusOn.getAccessibleContext().setAccessibleName("taFocusOn"); btnStart.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { storeDataAndStartTimer(); } }); btnStart.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { logger.debug(evt.getKeyCode() + ", " + evt.getKeyChar()); if (KeyEvent.VK_ENTER == evt.getKeyCode()) { storeDataAndStartTimer(); } } }); JLabel lblTitle = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_TITLE_LABEL)); pnlNewTimer.add(lblTitle, "cell 0 0"); pnlNewTimer.add(tfTitle, "cell 0 1 2 1,growx"); JLabel lblFocusOn = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_LABEL)); pnlNewTimer.add(lblFocusOn, "cell 0 2"); pnlNewTimer.add(spFocusOn, "cell 0 3 2 1,growx"); pnlNewTimer.add(btnStart, "cell 0 4 2 1,growx"); Box horizontalBox = Box.createHorizontalBox(); pnlNewTimer.add(horizontalBox, "flowx,cell 1 0"); JLabel lblDurata = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_DURATA_LABEL)); lblDurata.setHorizontalAlignment(SwingConstants.RIGHT); pnlNewTimer.add(lblDurata, "cell 1 0,alignx right"); lblDurata.setLabelFor(txtDurata); txtDurata = new JTextField("20"); txtDurata.setToolTipText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_DURATA_TOOL_TIP)); pnlNewTimer.add(txtDurata, "cell 1 0,alignx center"); txtDurata.setColumns(2); return pnlNewTimer; }
From source file:se.nawroth.asciidoc.browser.AsciidocBrowserApplication.java
public AsciidocBrowserApplication(final String[] args) { super("Asciidoc Browser"); setIconImage(Icons.APPLICATION.image()); setSize(1200, 1024);/*from www . j a v a 2 s.c o m*/ addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { actionExit(); } }); JPanel buttonPanel = new JPanel(); backButton = new JButton(""); backButton.setIcon(Icons.BACK.icon()); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { actionBack(); } }); buttonPanel.setLayout(new MigLayout("", "[1px][][][][]", "[1px]")); JButton btnOptionsbutton = new JButton(""); btnOptionsbutton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { settingsDialog.setVisible(true); } }); btnOptionsbutton.setIcon(Icons.OPTIONS.icon()); buttonPanel.add(btnOptionsbutton, "flowx,cell 0 0"); backButton.setEnabled(false); buttonPanel.add(backButton, "cell 0 0,grow"); forwardButton = new JButton(""); forwardButton.setIcon(Icons.FORWARD.icon()); forwardButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { actionForward(); } }); forwardButton.setEnabled(false); buttonPanel.add(forwardButton, "cell 0 0,grow"); getContentPane().setLayout(new MigLayout("", "[793.00px,grow]", "[44px][930px]")); getContentPane().add(buttonPanel, "cell 0 0,growx,aligny top"); locationTextField = new JTextField(65); locationTextField.setText(""); locationTextField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_TAB) { actionGo(); refreshDocumentTree(); } } }); locationTextField.setTransferHandler( new TextFieldTransferHandler(locationTextField.getTransferHandler(), new Runnable() { @Override public void run() { locationTextField.setText(""); } }, new Runnable() { @Override public void run() { actionGo(); refreshDocumentTree(); } })); homebutton = new JButton(""); homebutton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { locationTextField.setText(Settings.getHome()); actionGo(); refreshDocumentTree(); } }); refreshButton = new JButton(""); refreshButton.setToolTipText("Refresh"); refreshButton.setEnabled(false); refreshButton.setIcon(Icons.REFRESH.icon()); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { actionGo(); refreshPreview(); } }); buttonPanel.add(refreshButton, "cell 1 0"); homebutton.setIcon(Icons.HOME.icon()); buttonPanel.add(homebutton, "cell 2 0"); buttonPanel.add(locationTextField, "cell 3 0,grow"); treeSourceSplitPane = new JSplitPane(); treeSourceSplitPane.setResizeWeight(0.3); getContentPane().add(treeSourceSplitPane, "cell 0 1,grow"); treeScrollPane = new JScrollPane(); treeScrollPane.setMinimumSize(new Dimension(200, 200)); treeSourceSplitPane.setLeftComponent(treeScrollPane); documentTree = new DocumentTree(documentModel); documentTree.setCellRenderer(new TooltipsTreeCellRenderer()); ToolTipManager.sharedInstance().registerComponent(documentTree); ToolTipManager.sharedInstance().setInitialDelay(INITIAL_TOOLTIP_DELAY); ToolTipManager.sharedInstance().setReshowDelay(0); documentTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(final TreeSelectionEvent tse) { TreePath newLeadSelectionPath = tse.getNewLeadSelectionPath(); if (newLeadSelectionPath != null && !newLeadSelectionPath.equals(currentSelectionPath)) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) newLeadSelectionPath .getLastPathComponent(); FileWrapper file = (FileWrapper) node.getUserObject(); showFile(file, true); refreshPreview(); } } }); treeScrollPane.setViewportView(documentTree); sourceEditorPane = new JEditorPane(); sourceEditorPane.setContentType("text/html"); sourceEditorPane.setEditable(false); sourceEditorPane.addHyperlinkListener(new HandleHyperlinkUpdate()); JScrollPane fileScrollPane = new JScrollPane(sourceEditorPane); fileScrollPane.setMinimumSize(new Dimension(600, 600)); documentTabbedPane = new JTabbedPane(SwingConstants.BOTTOM); documentTabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(final ChangeEvent ce) { refreshPreview(); } }); sourceLogSplitPane = new JSplitPane(); sourceLogSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); treeSourceSplitPane.setRightComponent(sourceLogSplitPane); sourceLogSplitPane.setTopComponent(documentTabbedPane); documentTabbedPane.add(fileScrollPane); documentTabbedPane.setTitleAt(0, "Source"); browserPane = new BrowserPane(); previewScrollPane = new JScrollPane(browserPane); documentTabbedPane.addTab("Preview", null, previewScrollPane, null); console = new JConsole(); System.setErr(console.getErr()); System.setOut(console.getOut()); sourceLogSplitPane.setBottomComponent(console); executor = new AsciidocExecutor(); }
From source file:com.projity.dialog.AbstractDialog.java
protected JRootPane createRootPane() { ActionListener escapeListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { onCancel();/*ww w .j a v a 2 s . c o m*/ } }; ActionListener enterListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { onOk(); } }; ActionListener helpListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { onHelp(); } }; JRootPane rootPane = new JRootPane(); KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.registerKeyboardAction(escapeListener, escapeStroke, JComponent.WHEN_IN_FOCUSED_WINDOW); KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); rootPane.registerKeyboardAction(enterListener, enterStroke, JComponent.WHEN_IN_FOCUSED_WINDOW); KeyStroke f1Stroke = KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0); rootPane.registerKeyboardAction(helpListener, f1Stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
From source file:com.callidusrobotics.swing.SwingConsole.java
@Override public String getline(final int maxLen, final Color foreground, final Color background) throws ArrayIndexOutOfBoundsException { final StringBuffer stringBuffer = new StringBuffer(maxLen); boolean keepPolling = true; while (keepPolling) { if (stringBuffer.length() < maxLen) { showCursor();//from ww w. j av a2s. c o m } else { hideCursor(); } render(); final char input = getKeyTyped(); switch (input) { case KeyEvent.VK_ENTER: keepPolling = false; break; case KeyEvent.VK_BACK_SPACE: if (stringBuffer.length() > 0) { stringBuffer.deleteCharAt(stringBuffer.length() - 1); moveCursor(cursorRow, cursorCol - 1); print(cursorRow, cursorCol, ' ', background, background); } break; case KeyEvent.CHAR_UNDEFINED: case KeyEvent.VK_DELETE: case KeyEvent.VK_ESCAPE: // ignore these characters break; default: if (stringBuffer.length() < maxLen) { stringBuffer.append(input); print(cursorRow, cursorCol, input, foreground, background); moveCursor(cursorRow, cursorCol + 1); } } } hideCursor(); render(); return stringBuffer.toString(); }
From source file:org.dishevelled.brainstorm.BrainStorm.java
/** * Initialize components.//from w ww . j a va 2 s . c om */ private void initComponents() { Font font = new Font(chooseFontName(), Font.PLAIN, fontSize); hiddenCursor = createHiddenCursor(); textArea = new JTextArea() { /** {@inheritDoc} */ protected void paintComponent(final Graphics graphics) { Graphics2D g2 = (Graphics2D) graphics; g2.setRenderingHint(KEY_FRACTIONALMETRICS, VALUE_FRACTIONALMETRICS_ON); g2.setRenderingHint(KEY_TEXT_ANTIALIASING, VALUE_TEXT_ANTIALIAS_LCD_HRGB); super.paintComponent(g2); } }; textArea.setFont(font); textArea.setOpaque(true); textArea.setCursor(hiddenCursor); textArea.setBackground(backgroundColor); textArea.setForeground(textColor); textArea.setRows(rows); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); // clear all input mappings InputMap inputMap = textArea.getInputMap(); while (inputMap != null) { inputMap.clear(); inputMap = inputMap.getParent(); } // re-add select default input mappings textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "insert-break"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "insert-tab"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete-previous"); int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, keyMask), "delete-previous-word"); // add new input mappings textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, keyMask), "increase-font-size"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, keyMask), "decrease-font-size"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask), "save"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "quit"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, keyMask), "quit"); Action increaseFontSizeAction = new IncreaseFontSizeAction(); Action decreaseFontSizeAction = new DecreaseFontSizeAction(); Action saveAction = new SaveAction(); Action quitAction = new QuitAction(); textArea.getActionMap().put("increase-font-size", increaseFontSizeAction); textArea.getActionMap().put("decrease-font-size", decreaseFontSizeAction); textArea.getActionMap().put("save", saveAction); textArea.getActionMap().put("quit", quitAction); placeholder = Box.createGlue(); }
From source file:com.declarativa.interprolog.gui.Ini2BCKP.java
/*********************/ public Ini2BCKP(AbstractPrologEngine e, boolean autoDisplay) { /// super("PrologEngine listener (Swing)"); System.out.println("ENTRA"); if (e != null) { engine = e;/*w ww . j a va 2s . c om*/ } else { throw new IPException("missing Prolog engine"); } String VF = e.getImplementationPeer().visualizationFilename(); if (engine.getLoadFromJar()) { engine.consultFromPackage(VF, Ini2BCKP.class); } else { engine.consultRelative(VF, Ini2BCKP.class); } engine.teachMoreObjects(guiExamples()); if (engine == null) { dispose(); // no interface object permitted! } else { topLevelCount++; } debug = engine.isDebug(); loadedFiles = new Vector(); initComponents(); //constructWindowContents(); /// constructMenu(); addWindowListener(this); prologInput.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { // sendToProlog(); e.consume(); } } }); //prologOutput.append("Welcome to an InterProlog top level\n" + e.getPrologVersion() + "\n\n"); prologOutput.append("\n ARG ENGINE v18 ALPHA "); prologOutput.append("\t Argument Engine based on WFS \n\n"); prologOutput.append("\t UIKM Group - Umea University \n\n"); prologOutput.append("\t {esteban, jcnieves, helena}@cs.umu.se \n\n"); if (autoDisplay) { setVisible(true); // focusInput(); } }
From source file:plugin.notes.gui.JIcon.java
private void buttonKeyReleased(KeyEvent evt) { int key = evt.getKeyCode(); if (key == KeyEvent.VK_DELETE) { deleteFile();//www .j a v a2 s . c o m } else if (key == KeyEvent.VK_ENTER) { launchFile(); } }
From source file:org.openmicroscopy.shoola.util.ui.NumericalTextField.java
/** * Creates a new instance.// w w w .j a v a 2 s . c o m * * @param min The minimum value of the text field. * @param max The maximum value of the text field. * @param type The number type. */ public NumericalTextField(double min, double max, Class<?> type) { document = new NumericalPlainDocument(min, max); setHorizontalAlignment(JTextField.RIGHT); setDocument(document); originalText = null; editedColor = null; document.addDocumentListener(this); addFocusListener(this); addKeyListener(new KeyAdapter() { /** * Checks if the text is valid. * @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { String s = getText(); String v = checkValue(); if (v != null && !v.equals(s)) { setText(v); } } } }); numberType = type; accepted = NUMERIC; setNegativeAccepted(min < 0); }
From source file:com.fanniemae.ezpie.actions.HighlightScan.java
private void changeOracleExtractExtension(File castExtractionFile) { ProcessBuilder pb = new ProcessBuilder("java", "-jar", _dbDeliveryToolPath); Process process = null;/* ww w. j av a 2 s. com*/ Robot robot = null; try { process = pb.start(); robot = new Robot(); } catch (IOException | AWTException e) { throw new PieException("Could not start Oracle extract.", e); } sleep(15000); // navigating to input text for (int i = 0; i < 3; i++) { keyPressRelease(KeyEvent.VK_TAB, 200); sleep(200); } // select populated target folder path keyPressReleaseControlA(500); // entering target folder path Keyboard keyboard = new Keyboard(robot); keyboard.type(castExtractionFile.getParent() + "\\deliveryResults"); // navigate to options keyPressReleaseShiftTab(200); keyPressRelease(KeyEvent.VK_RIGHT, 500); for (int i = 0; i < 2; i++) { keyPressRelease(KeyEvent.VK_TAB, 200); sleep(200); } // select populated extraction file path keyPressReleaseControlA(500); // entering target folder path that contains .castextraction file keyboard.type(castExtractionFile.getPath()); sleep(500); keyPressRelease(KeyEvent.VK_TAB, 200); sleep(500); // navigate to menu bar to select Application/Run Application since tabbing to 'Run Application' button // and pressing enter does not execute run keyPressRelease(KeyEvent.VK_ALT, 500); sleep(500); for (int i = 0; i < 2; i++) { keyPressRelease(KeyEvent.VK_RIGHT, 200); } keyPressRelease(KeyEvent.VK_ENTER, 200); keyPressRelease(KeyEvent.VK_DOWN, 500); keyPressRelease(KeyEvent.VK_ENTER, 200); sleep(5000); process.destroy(); }
From source file:edu.ku.brc.af.ui.db.JAutoCompTextField.java
protected void keyReleasedInternal(KeyEvent ev) { //System.out.println(ev); if (dbAdapter != null) { if (ev.getKeyCode() == JAutoCompComboBox.SEARCH_KEY) { /*lookup(getText()); //from w w w . j ava 2s.c om if (!foundMatch) { setText(""); }*/ ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent ae) { JMenuItem mi = (JMenuItem) ae.getSource(); int inx = 0; for (PickListItemIFace pli : dbAdapter.getList()) { String title = pli.getTitle(); if (mi.getText().equals(title)) { setSelectedIndex(inx); break; } inx++; } popupMenu = null; } }; String txt = getText(); int cnt = 0; for (PickListItemIFace pli : dbAdapter.getList()) { String title = pli.getTitle(); if (title.length() >= txt.length() && title.startsWith(txt)) { cnt++; } } if (cnt > 0) { popupMenu = new JPopupMenu(); for (PickListItemIFace pli : dbAdapter.getList()) { String title = pli.getTitle(); if (title.length() >= txt.length() && title.startsWith(txt)) { JMenuItem mi = new JMenuItem(title); setControlSize(mi); popupMenu.add(mi); mi.addActionListener(al); } } Point location = getLocation(); Dimension size = getSize(); popupMenu.show(this, location.x, location.y + size.height); } } else if (ev.getKeyCode() == KeyEvent.VK_ENTER) { addNewItemFromTextField(); } else if (ev.getKeyCode() == KeyEvent.VK_END)// || ev.getKeyCode() == KeyEvent.VK_SHIFT) { setSelectionStart(prevCaretPos); setSelectionEnd(getText().length()); } /*else { char key = ev.getKeyChar(); if (ev.getKeyCode() == KeyEvent.VK_BACK_SPACE) { String s = getText(); if (foundMatch) { //System.out.println("len ["+s.length()+"]"); //System.out.println(s+"["+s.substring(0, s.length()-1)+"]"); setText(s.length() == 0 ? "" : s.substring(0, s.length()-1)); } else { hasChanged = true; } return; } else if ((!(Character.isLetterOrDigit(key) || Character.isSpaceChar(key))) && ev.getKeyCode() != KeyEvent.VK_DELETE) { if (ev.getKeyCode() == KeyEvent.VK_ENTER) { addNewItemFromTextField(); } //System.out.println("Key Code "+ev.getKeyCode()+" Pos: "+getCaretPosition()+" Del: "+KeyEvent.VK_DELETE); if (ev.getKeyCode() == KeyEvent.VK_END)// || ev.getKeyCode() == KeyEvent.VK_SHIFT) { setSelectionStart(prevCaretPos); setSelectionEnd(getText().length()); } return; } else if(ev.getKeyCode() == KeyEvent.VK_DELETE) { foundMatch = false; hasChanged = true; return; } //System.out.println("["+ev.getKeyCode()+"]["+KeyEvent.VK_DELETE+"]"); caretPos = getCaretPosition(); String text = ""; try { text = getText(0, caretPos); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(JAutoCompTextField.class, ex); ex.printStackTrace(); } lookup(text); }*/ } }