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.headswilllol.basiclauncher.Launcher.java
public Launcher() { f.setTitle(NAME + " Launcher"); if (progress == null) { this.setLayout(null); play = new JButton("Play Game"); play.setVerticalTextPosition(AbstractButton.CENTER); play.setHorizontalTextPosition(AbstractButton.CENTER); play.setMnemonic(KeyEvent.VK_ENTER); play.setActionCommand("play"); play.addActionListener(this); play.setPreferredSize(new Dimension(btnWidth, btnHeight)); play.setBounds((width / 2) - (btnWidth / 2), 125, btnWidth, btnHeight); this.add(play); force = new JButton("Force Update"); force.setVerticalTextPosition(AbstractButton.CENTER); force.setHorizontalTextPosition(AbstractButton.CENTER); force.setMnemonic(KeyEvent.VK_ENTER); force.setActionCommand("force"); force.addActionListener(this); force.setPreferredSize(new Dimension(btnWidth, btnHeight)); force.setBounds((width / 2) - (btnWidth / 2), 200, btnWidth, btnHeight); this.add(force); noUpdate = new JButton("Do Not Reacquire"); noUpdate.setVerticalTextPosition(AbstractButton.CENTER); noUpdate.setHorizontalTextPosition(AbstractButton.CENTER); noUpdate.setMnemonic(KeyEvent.VK_ENTER); noUpdate.setActionCommand("noReacquire"); noUpdate.addActionListener(this); noUpdate.setPreferredSize(new Dimension(btnWidth, btnHeight)); noUpdate.setBounds((width / 2) - (btnWidth / 2), 275, btnWidth, btnHeight); this.add(noUpdate); quit = new JButton("Exit Launcher"); quit.setVerticalTextPosition(AbstractButton.CENTER); quit.setHorizontalTextPosition(AbstractButton.CENTER); quit.setMnemonic(KeyEvent.VK_ESCAPE); quit.setActionCommand("quit"); quit.addActionListener(this); quit.setPreferredSize(new Dimension(btnWidth, btnHeight)); quit.setBounds((width / 2) - (btnWidth / 2), 350, btnWidth, btnHeight); this.add(quit); }//from w ww. ja v a2 s . c om launcher = this; }
From source file:ch.fork.AdHocRailway.ui.locomotives.configuration.LocomotiveConfig.java
private void initShortcuts() { GlobalKeyShortcutHelper.registerKey(getRootPane(), KeyEvent.VK_ENTER, 0, new ApplyChangesAction()); }
From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewParametersDialog.java
private void initialize(final MasterReport report) { if (report == null) { throw new NullPointerException(); }/*from w w w .j a va 2 s .com*/ masterReport = report; messages = new ResourceBundleSupport(Locale.getDefault(), SwingPreviewModule.BUNDLE_NAME, ObjectUtilities.getClassLoader(PreviewParametersDialog.class)); confirmAction = new OkAction(); setTitle(messages.getString("PreviewParametersDialog.Title")); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); final JPanel contentPane = new JPanel(); contentPane.setLayout(new BorderLayout()); contentPane.add(createParametersPanel(), BorderLayout.CENTER); contentPane.add(createButtonsPanel(), BorderLayout.SOUTH); setContentPane(contentPane); final InputMap inputMap = contentPane.getInputMap(); final ActionMap actionMap = contentPane.getActionMap(); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "confirm"); // NON-NLS inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NON-NLS actionMap.put("confirm", new OkAction()); // NON-NLS actionMap.put("cancel", new CancelAction()); // NON-NLS setModal(true); pack(); LibSwingUtil.centerDialogInParent(this); }
From source file:com.emental.mindraider.ui.dialogs.AttachmentJDialog.java
/** * Concetructor./*from w w w.ja va 2 s . c o m*/ * * @param noteResource * The concept resource. * @param dragAndDropReference * The drag'n'drop reference. */ public AttachmentJDialog(ConceptResource conceptResource, DragAndDropReference dragAndDropReference) { super(Messages.getString("AttachmentJDialog.title")); this.conceptResource = conceptResource; getContentPane().setLayout(new BorderLayout()); JPanel p, pp; p = new JPanel(); p.setLayout(new BorderLayout()); JLabel intro = new JLabel("<html> " + Messages.getString("AttachmentJDialog.introduction") + " <br><br></html>"); p.add(intro, BorderLayout.NORTH); p.add(new JLabel("<html> " + Messages.getString("AttachmentJDialog.description") + "</html>"), BorderLayout.CENTER); description = new JTextField(38); pp = new JPanel(new FlowLayout(FlowLayout.LEFT)); pp.add(description); p.add(pp, BorderLayout.SOUTH); getContentPane().add(p, BorderLayout.NORTH); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.setBorder(new TitledBorder(Messages.getString("AttachmentJDialog.resource"))); ButtonGroup attachType = new ButtonGroup(); JPanel webPanel = new JPanel(); webPanel.setLayout(new BorderLayout()); webType = new JRadioButton(Messages.getString("AttachmentJDialog.web")); webType.setActionCommand(WEB); webType.addActionListener(this); webType.setSelected(true); attachType.add(webType); webPanel.add(webType, BorderLayout.NORTH); urlTextField = new JTextField("http://", 35); urlTextField.selectAll(); urlTextField.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { attach(); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.add(new JLabel(" ")); p.add(urlTextField); webPanel.add(p, BorderLayout.SOUTH); mainPanel.add(webPanel, BorderLayout.NORTH); JPanel localPanel = new JPanel(); localPanel.setLayout(new BorderLayout()); JRadioButton localType = new JRadioButton(Messages.getString("AttachmentJDialog.local")); localType.setActionCommand(LOCAL); localType.addActionListener(this); localPanel.add(localType, BorderLayout.NORTH); pathTextField = new JTextField(35); pathTextField.setEnabled(false); browseButton = new JButton(Messages.getString("AttachmentJDialog.browse")); browseButton.setToolTipText(Messages.getString("AttachmentJDialog.browseTip")); browseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("AttachmentJDialog.attach")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("AttachmentJDialog.chooseAttachment")); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); int returnVal = fc.showOpenDialog(AttachmentJDialog.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); pathTextField.setText(file.toString()); } } }); browseButton.setEnabled(false); pp = new JPanel(); pp.setLayout(new BorderLayout()); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.add(new JLabel(" ")); pp.add(p, BorderLayout.NORTH); p.add(pathTextField); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(browseButton); pp.add(p, BorderLayout.SOUTH); localPanel.add(pp, BorderLayout.SOUTH); attachType.add(localType); mainPanel.add(localPanel, BorderLayout.SOUTH); getContentPane().add(mainPanel, BorderLayout.CENTER); // buttons p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton addButton = new JButton(Messages.getString("AttachmentJDialog.attach")); p.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { attach(); } }); JButton cancelButton = new JButton(Messages.getString("AttachmentJDialog.cancel")); p.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AttachmentJDialog.this.dispose(); } }); getContentPane().add(p, BorderLayout.SOUTH); /* * drag and drop initialization */ if (dragAndDropReference != null) { if (dragAndDropReference.getType() == DragAndDropReference.BROWSER_LINK) { urlTextField.setText(dragAndDropReference.getReference()); localType.setSelected(false); webType.setSelected(true); enableWebTypeButtons(); } else { pathTextField.setText(dragAndDropReference.getReference()); localType.setSelected(true); webType.setSelected(false); enableLocalTypeButtons(); } description.setText(dragAndDropReference.getTitle()); } pack(); Gfx.centerAndShowWindow(this); }
From source file:com.github.alexfalappa.nbspringboot.cfgprops.completion.CfgPropCompletionItem.java
@Override public void processKeyEvent(KeyEvent evt) { // detect if Ctrl + Enter is pressed overwrite = evt.getKeyCode() == KeyEvent.VK_ENTER && (evt.getModifiers() & KeyEvent.CTRL_MASK) != 0; }
From source file:com.chaosting.product.hotkey.Main.java
/** * case ascii in (33,34,35,36,37,38,40...)shiftkeycode,keyperss(shift)keyrelease(shift) * /* w ww . j a v a2 s . c o m*/ * String temp = "!@#$%^&()_+{}|:\"<>?"; * String temp = "*-=[]\\;',./"; * * @param ascii * @return */ private int convertAsciiInt2KeycodeInt(int ascii) { if (ascii >= 65 && ascii <= 90) { return ascii; } if (ascii >= 48 && ascii <= 57) { return ascii + 48; } if (ascii >= 97 && ascii <= 122) { return ascii - 32; } switch (ascii) { case 13: return KeyEvent.VK_ENTER; case 32: return KeyEvent.VK_SPACE; //case 33: // return KeyEvent.VK_EXCLAMATION_MARK; //case 34: // return KeyEvent.VK_QUOTEDBL; //case 35: // return KeyEvent.VK_NUMBER_SIGN; //case 36: // return KeyEvent.VK_DOLLAR; // 37 % // 38 & case 39: return KeyEvent.VK_QUOTE; //case 40: // return KeyEvent.VK_LEFT_PARENTHESIS; //case 41: // return KeyEvent.VK_RIGHT_PARENTHESIS; case 42: return KeyEvent.VK_MULTIPLY; //case 43: // return KeyEvent.VK_PLUS; case 44: return KeyEvent.VK_COMMA; case 45: return KeyEvent.VK_MINUS; case 46: return KeyEvent.VK_PERIOD; case 47: return KeyEvent.VK_SLASH; //case 58: // return KeyEvent.VK_COLON; case 59: return KeyEvent.VK_SEMICOLON; //case 60: // return KeyEvent.VK_LESS; case 61: return KeyEvent.VK_EQUALS; //case 62: // return KeyEvent.VK_GREATER; // 63 ? //case 64: // return KeyEvent.VK_AT; case 91: return KeyEvent.VK_OPEN_BRACKET; case 92: return KeyEvent.VK_BACK_SLASH; case 93: return KeyEvent.VK_CLOSE_BRACKET; //case 94: // return KeyEvent.VK_CIRCUMFLEX; //case 95: // return KeyEvent.VK_UNDERSCORE; // 96 ` //case 123: // return KeyEvent.VK_BRACELEFT; // 124 | //case 125: // return KeyEvent.VK_BRACERIGHT; // 126 ~ default: return -1; } }
From source file:org.orbisgis.view.sqlconsole.ui.SQLConsolePanel.java
/** * Create actions instances/*from w w w .j a va 2 s.c o m*/ * * Each action is put in the Popup menu and the tool bar * Their shortcuts are registered also in the editor */ private void initActions() { //Execute Action executeAction = new DefaultAction(SQLAction.A_EXECUTE, I18N.tr("Execute"), I18N.tr("Run SQL statements"), OrbisGISIcon.getIcon("execute"), EventHandler.create(ActionListener.class, this, "onExecute"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom"); actions.addAction(executeAction); //Clear action clearAction = new DefaultAction(SQLAction.A_CLEAR, I18N.tr("Clear"), I18N.tr("Erase the content of the editor"), OrbisGISIcon.getIcon("erase"), EventHandler.create(ActionListener.class, this, "onClear"), null).setLogicalGroup("custom") .setAfter(SQLAction.A_EXECUTE); actions.addAction(clearAction); //Find action findAction = new DefaultAction(SQLAction.A_SEARCH, I18N.tr("Search.."), I18N.tr("Search text in the document"), OrbisGISIcon.getIcon("find"), EventHandler.create(ActionListener.class, this, "openFindReplaceDialog"), KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK)) .addStroke(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK)) .setLogicalGroup("custom"); actions.addAction(findAction); //Quote quoteAction = new DefaultAction(SQLAction.A_QUOTE, I18N.tr("Quote"), I18N.tr("Quote selected text"), null, EventHandler.create(ActionListener.class, this, "onQuote"), KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, InputEvent.SHIFT_DOWN_MASK)).setLogicalGroup("format"); actions.addAction(quoteAction); //unQuote unQuoteAction = new DefaultAction(SQLAction.A_UNQUOTE, I18N.tr("Un Quote"), I18N.tr("Un Quote selected text"), null, EventHandler.create(ActionListener.class, this, "onUnQuote"), KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, InputEvent.SHIFT_DOWN_MASK)) .setLogicalGroup("format"); actions.addAction(unQuoteAction); //Format SQL formatSQLAction = new DefaultAction(SQLAction.A_FORMAT, I18N.tr("Format"), I18N.tr("Format editor content"), null, EventHandler.create(ActionListener.class, this, "onFormatCode"), KeyStroke.getKeyStroke("alt shift F")).setLogicalGroup("format"); actions.addAction(formatSQLAction); //Save saveAction = new DefaultAction(SQLAction.A_SAVE, I18N.tr("Save"), I18N.tr("Save the editor content into a file"), OrbisGISIcon.getIcon("save"), EventHandler.create(ActionListener.class, this, "onSaveFile"), KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom"); actions.addAction(saveAction); //Open action actions.addAction( new DefaultAction(SQLAction.A_OPEN, I18N.tr("Open"), I18N.tr("Load a file in this editor"), OrbisGISIcon.getIcon("open"), EventHandler.create(ActionListener.class, this, "onOpenFile"), KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)) .setLogicalGroup("custom")); //ShowHide function list actions.addAction(new DefaultAction(SQLAction.A_SQL_LIST, I18N.tr("SQL list"), I18N.tr("Show/Hide SQL function list"), OrbisGISIcon.getIcon("builtinfunctionmap"), EventHandler.create(ActionListener.class, sqlFunctionsPanel, "switchPanelVisibilityState"), null) .setLogicalGroup("custom")); }
From source file:ru.codemine.pos.ui.salespanel.QuantitySetupWindow.java
public void setupActionListeners() { okButton.addActionListener(setQuantityListener); cancelButton.addActionListener(new ActionListener() { @Override// w w w .java2 s . c om public void actionPerformed(ActionEvent e) { mainWindow.unblockBarcodeInput(); setVisible(false); } }); spinner.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { okButton.doClick(); } } }); actionListenersInit = true; }
From source file:jdroidremote.ServerFrame.java
public static void typeCharacter(String letter) { System.out.println(letter);/*from w w w .j a v a2 s .c o m*/ Robot robot = null; try { robot = new Robot(); } catch (Exception ex) { ex.printStackTrace(); } if (Character.isLetter(letter.charAt(0))) { try { boolean upperCase = Character.isUpperCase(letter.charAt(0)); String variableName = "VK_" + letter.toUpperCase(); KeyEvent ke = new KeyEvent(new JTextField(), 0, 0, 0, 0, ' '); Class clazz = ke.getClass(); Field field = clazz.getField(variableName); int keyCode = field.getInt(ke); //System.out.println(keyCode + " = keyCode"); robot.delay(80); if (upperCase) { robot.keyPress(KeyEvent.VK_SHIFT); } robot.keyPress(keyCode); robot.keyRelease(keyCode); if (upperCase) { robot.keyRelease(KeyEvent.VK_SHIFT); } } catch (Exception e) { System.out.println(e); } } else if (letter.equals(".")) { robot.keyPress(KeyEvent.VK_PERIOD); //keyCode 46 robot.keyRelease(KeyEvent.VK_PERIOD); } else if (letter.equals("!")) { robot.keyPress(KeyEvent.VK_SHIFT); //keyCode 16 robot.keyPress(KeyEvent.VK_1); //keycode 49 robot.keyRelease(KeyEvent.VK_1); robot.keyRelease(KeyEvent.VK_SHIFT); } else if (letter.equals(" ")) { robot.keyPress(KeyEvent.VK_SPACE); robot.keyRelease(KeyEvent.VK_SPACE); } else if (letter.equals("?")) { robot.keyPress(KeyEvent.VK_SHIFT); //keyCode 16 robot.keyPress(KeyEvent.VK_SLASH); //keyCode 47 robot.keyRelease(KeyEvent.VK_SLASH); robot.keyRelease(KeyEvent.VK_SHIFT); } else if (letter.equals(",")) { robot.keyPress(KeyEvent.VK_COMMA); robot.keyRelease(KeyEvent.VK_COMMA); } else if (letter.equals("@enter")) { robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); } else if (letter.equals("@backspace")) { robot.keyPress(KeyEvent.VK_BACK_SPACE); robot.keyRelease(KeyEvent.VK_BACK_SPACE); } }
From source file:dataviewer.DataViewer.java
/** * Creates new form DataViewer//from w w w. j a v a2 s. com */ public DataViewer() { try { for (Enum ee : THREAD.values()) { t[ee.ordinal()] = new Thread(); } initComponents(); DropTarget dropTarget = new DropTarget(tr_files, new DropTargetListenerImpl()); TreeSelectionListener treeSelectionListener = new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { javax.swing.JTree tree = (javax.swing.JTree) e.getSource(); TreePath path = tree.getSelectionPath(); Object[] pnode = (Object[]) path.getPath(); String name = pnode[pnode.length - 1].toString(); String ex = getExtension(name); if (ex.equals(".txt") || ex.equals(".dat") || ex.equals(".csv") || ex.equals(".tsv")) { selected_file = name; } else { selected_file = ""; } } }; tr_files.addTreeSelectionListener(treeSelectionListener); tr_files.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() >= 2) { if (!"".equals(selected_file)) { //count_data(); read_data(); } else { TreePath path = tr_files.getSelectionPath(); if (path.getLastPathComponent().toString().equals(cur_path)) { cur_path = (new File(cur_path)).getParent(); } else { cur_path = cur_path + File.separator + path.getLastPathComponent().toString(); } fill_tree(); } } } }); tr_files.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_BACK_SPACE) { cur_path = (new File(cur_path)).getParent(); fill_tree(); } else if (evt.getKeyCode() == KeyEvent.VK_ENTER) { if (!"".equals(selected_file)) { //count_data(); read_data(); } else { TreePath path = tr_files.getSelectionPath(); if (path.getLastPathComponent().toString().equals(cur_path)) { cur_path = (new File(cur_path)).getParent(); } else { cur_path = cur_path + File.separator + path.getLastPathComponent().toString(); } fill_tree(); } } else if (evt.getKeyCode() == KeyEvent.VK_DELETE) { if (!"".equals(selected_file)) { String name = cur_path + File.separator + selected_file; if ((new File(name)).isFile()) { int dialogResult = JOptionPane.showConfirmDialog(null, "Selected file [" + selected_file + "] will be removed and not recoverable.", "Are you sure?", JOptionPane.YES_NO_OPTION); if (dialogResult == JOptionPane.YES_OPTION) { (new File(name)).delete(); fill_tree(); } } } else { JOptionPane.showMessageDialog(null, "For safety concern, removing folder is not supported.", "Information", JOptionPane.ERROR_MESSAGE); } } } }); tr_files.setCellRenderer(new MyTreeCellRenderer()); p_count.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); //tp_menu.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ctrl1, "tab_read"); //tp_menu.getActionMap().put("tab_read", (Action) new ActionListenerImpl()); //tp_menu.setMnemonicAt(0, KeyEvent.VK_1); //tp_menu.setMnemonicAt(1, KeyEvent.VK_2); /*InputMap inputMap = tp_menu.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap actionMap = tp_menu.getActionMap(); KeyStroke ctrl1 = KeyStroke.getKeyStroke("ctrl 1"); inputMap.put(ctrl1, "tab_read"); actionMap.put("tab_read", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { tp_menu.setSelectedIndex(0); } }); KeyStroke ctrl2 = KeyStroke.getKeyStroke("ctrl 2"); inputMap.put(ctrl2, "tab_analyze"); actionMap.put("tab_analyze", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { tp_menu.setSelectedIndex(1); } });*/ config(); } catch (Exception e) { txt_count.setText(e.getMessage()); } }