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:gtu._work.etc.EnglishAdd.java
private void initGUI() { try {/*from ww w . j av a 2 s. c o m*/ BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); this.setPreferredSize(new java.awt.Dimension(400, 211)); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); jTabbedPane1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { if (jTabbedPane1.getSelectedIndex() == 2) { // XXX } } }); { jPanel1 = new JPanel(); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("add", null, jPanel1, null); jPanel1.setPreferredSize(new java.awt.Dimension(387, 233)); { showwordText = new JTextField(); jPanel1.add(showwordText); showwordText.setPreferredSize(new java.awt.Dimension(271, 23)); showwordText.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ENTER) { scanWord(); } } }); showwordText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { scanWord(); } }); } { netChkBox = new JCheckBox(); jPanel1.add(netChkBox); netChkBox.setSelected(true); } { jScrollPane2 = new JScrollPane(); jPanel1.add(jScrollPane2); jScrollPane2.setPreferredSize(new java.awt.Dimension(364, 80)); { showChineseArea = new JTextArea(); jScrollPane2.setViewportView(showChineseArea); showChineseArea.setPreferredSize(new java.awt.Dimension(364, 80)); } } { setFileBtn = new JButton(); jPanel1.add(setFileBtn); setFileBtn.setText("set file"); setFileBtn.setPreferredSize(new java.awt.Dimension(261, 30)); setFileBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JCommonUtil._jFileChooser_selectFileOnly(); if (file == null) { JCommonUtil._jOptionPane_showMessageDialog_error("?!"); return; } currentFile = file; StringBuffer sb = new StringBuffer(); try { BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(currentFile), "BIG5")); for (String line = null; (line = reader.readLine()) != null;) { sb.append(line + "\r\n"); } reader.close(); } catch (IOException e) { e.printStackTrace(); } wordTextArea.setText(sb.toString()); } }); } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("word", null, jPanel3, null); { jScrollPane1 = new JScrollPane(); jPanel3.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(387, 224)); { wordTextArea = new JTextArea(); jScrollPane1.setViewportView(wordTextArea); } } } } setDefaultSave(); pack(); this.setSize(400, 211); } catch (Exception e) { // add your error handling code here e.printStackTrace(); } }
From source file:org.objectpocket.viewer.Viewer.java
/** * Initialize the contents of the frame. *///w w w . ja v a2s .c o m private void initialize() { viewerFrame = new JFrame(); viewerFrame.setTitle("ObjectPocketViewer"); viewerFrame.setBounds(100, 100, 1427, 524); viewerFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); splitPane = new JSplitPane(); splitPane.setResizeWeight(0.2); viewerFrame.getContentPane().add(splitPane, BorderLayout.CENTER); classTree = new JTree(); classTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); classTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { updateTable(); } }); splitPane.setLeftComponent(classTree); panel = new JPanel(); splitPane.setRightComponent(panel); panel.setLayout(new BorderLayout(0, 0)); scrollPane = new JScrollPane(); panel.add(scrollPane); objectTable = new JTable(); objectTable.setAutoCreateRowSorter(true); objectTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); scrollPane.setViewportView(objectTable); panel.add(scrollPane, BorderLayout.CENTER); filterPanel = new JPanel(); panel.add(filterPanel, BorderLayout.NORTH); filterPanel.setLayout(new BorderLayout(0, 0)); filterTextField = new JTextField(); filterTextField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ENTER) { updateTable(); } } }); filterPanel.add(filterTextField, BorderLayout.CENTER); filterTextField.setColumns(10); filterButton = new JButton("apply filter"); filterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateTable(); } }); filterPanel.add(filterButton, BorderLayout.EAST); statusLabel = new JLabel(""); panel.add(statusLabel, BorderLayout.SOUTH); }
From source file:org.openmicroscopy.shoola.agents.imviewer.util.player.MoviePlayerControl.java
/** Adds listeners to the UI components. */ private void initListeners() { JTextField editor = view.editor; editor.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) editorActionHandler();/* w w w. j a v a 2s.co m*/ } }); //JButton attachButtonListener(view.play, PLAY_CMD); attachButtonListener(view.pause, PAUSE_CMD); attachButtonListener(view.stop, STOP_CMD); //JComboBox JComboBox box = view.movieTypes; box.setActionCommand("" + MOVIE_TYPE_CMD); box.addActionListener(this); //JSpinner view.fps.addChangeListener(this); //MoviePane attachFieldListeners(view.startT); attachFieldListeners(view.endT); attachFieldListeners(view.startZ); attachFieldListeners(view.endZ); attachButtonListener(view.acrossZ, ACROSS_Z_CMD); attachButtonListener(view.acrossT, ACROSS_T_CMD); //attachButtonListener(view.acrossZT, ACROSS_ZT_CMD); view.tSlider.addPropertyChangeListener(this); view.zSlider.addPropertyChangeListener(this); }
From source file:org.lisapark.octopus.swing.BaseFormattedTextField.java
/** * Invoked to process the key bindings for <code>ks</code> as the result * of the <code>KeyEvent</code> <code>e</code>. We override this method to make * sure that the text field has the proper action for when the user presses * the enter key/* www. jav a 2 s . co m*/ * * @param ks the <code>KeyStroke</code> queried * @param e the <code>KeyEvent</code> * @param condition one of the following values: * <ul> * <li>JComponent.WHEN_FOCUSED * <li>JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT * <li>JComponent.WHEN_IN_FOCUSED_WINDOW * </ul> * @param pressed true if the key is pressed * @return true if there was a binding to an action, and the action * was enabled */ protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) { // we need to override this method to allow for handling of the delete key properly if (e.getKeyCode() == KeyEvent.VK_ENTER) { InputMap map = getInputMap(condition); ActionMap am = getActionMap(); if (map != null && am != null && isEnabled()) { Object binding = map.get(ks); Action action; // replace the nofify action if necessary if (binding != null && binding.equals(JTextField.notifyAction)) { action = am.get(binding); if (action != commitOnEnterAction) { am.put(JTextField.notifyAction, commitOnEnterAction); } } } } return super.processKeyBinding(ks, e, condition, pressed); }
From source file:org.openestate.tool.helloworld.HelloWorldFrameSidebarExtension.java
@Override public JComponent createComponent() { // create the component, that is shown in the sidebar final HelloWorldList list = new HelloWorldList(); list.setModel(ObjectUtils.defaultIfNull(createListModel(), new DefaultListModel<>())); list.setCellRenderer(new HelloWorldListRenderer()); // register keyboard events list.addKeyListener(new KeyAdapter() { @Override/*w w w .ja v a 2s.c o m*/ public void keyPressed(KeyEvent e) { if (!list.isEnabled()) return; // ENTER was pressed if (e.getKeyCode() == KeyEvent.VK_ENTER) { DbHelloWorldObject object = list.getSelectedValue(); if (object != null) new HelloWorldPlugin.ObjectFormAction(object.id).actionPerformed(null); } } }); // register mouse events list.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (!list.isEnabled()) return; // single click with the right mouse button if (e.getButton() == MouseEvent.BUTTON3 && e.getClickCount() == 1) { // fetch the clicked element int index = list.locationToIndex(e.getPoint()); if (index >= 0) list.setSelectedIndex(index); // show popup menu with further actions DbHelloWorldObject object = list.getSelectedValue(); JPopupMenu popup = createActionMenu(object); if (popup != null) popup.show(list, e.getPoint().x, e.getPoint().y); } // double click with the left mouse button else if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { DbHelloWorldObject object = list.getSelectedValue(); if (object != null) new HelloWorldPlugin.ObjectFormAction(object.id).actionPerformed(null); } } }); return list; }
From source file:org.domainmath.gui.FileTreePanel.java
/** * Creates new form FileTreePanel/*from ww w . j a v a 2 s .c o m*/ * @param frame */ public FileTreePanel(MainFrame frame) { initComponents(); this.frame = frame; fileTree.setEditable(true); addPopupMenuToFileTree(); ToolTipManager.sharedInstance().registerComponent(fileTree); // handle right click event on File Tree. fileTree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.getClickCount() == 2) { TreePath path = fileTree.getPathForLocation(e.getX(), e.getY()); Rectangle pathBounds = fileTree.getUI().getPathBounds(fileTree, path); if (pathBounds != null && pathBounds.contains(e.getX(), e.getY())) { File file = (File) fileTree.getLastSelectedPathComponent(); selectFile(file); } } } }); keyDeleteItem = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0); keyRenameItem = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0); keyOpenItem = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); keyRefreshItem = KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0); }
From source file:kenh.xscript.elements.Debug.java
@Override public void keyPressed(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ENTER) { Object obj = e.getSource(); if (obj instanceof JTextField) { parse((JTextField) obj); }//from w w w .ja v a 2s. co m } }
From source file:com.nvinayshetty.DTOnator.Ui.InputWindow.java
private void initListeners() { inputFeedText.addMouseListener(new ContextMenuMouseListener()); inputFeedText.addKeyListener(new KeyListener() { @Override// w ww . java 2 s. co m public void keyTyped(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: onOK(); break; case KeyEvent.VK_ESCAPE: onCancel(); break; } } @Override public void keyReleased(KeyEvent e) { } }); makeFieldsPrivate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (makeFieldsPrivate.isSelected()) { setEncapsulationOptionsVisible(true); SetEncapsulationOptionsSelected(true); } else { setEncapsulationOptionsVisible(false); } } }); }
From source file:org.nuclos.client.layout.wysiwyg.editor.ui.panels.WYSIWYGMetaInformationPicker.java
/** * // www . j ava2 s.c o m * @param values * @param parent */ private WYSIWYGMetaInformationPicker(Window owner, List<String> values, TableLayoutPanel parent) { super(owner); this.setIconImage(NuclosIcons.getInstance().getScaledDialogIcon(48).getImage()); Container contentPane = this.getContentPane(); contentPane.setLayout(new TableLayout(layoutDefinition)); originalValues = values; filter = new JTextField(); /** the keybinding*/ filter.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { /** up and down cursor for selecting the next or previous entry */ if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) { int selectedItem = itemList.getSelectedIndex(); if (e.getKeyCode() == KeyEvent.VK_UP) selectedItem--; else if (e.getKeyCode() == KeyEvent.VK_DOWN) selectedItem++; if (selectedItem < 0) { selectedItem = listModel.getSize() - 1; } else if (selectedItem == listModel.getSize()) { selectedItem = 0; } itemList.setSelectedIndex(selectedItem); itemList.ensureIndexIsVisible(selectedItem); } else if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_ESCAPE) { /** enter for saving, esc for cancel */ if (e.getKeyCode() == KeyEvent.VK_ESCAPE) selectedEntity = null; dispose(); } else { /** every other key is used for filtering the entries */ filterItems(WYSIWYGMetaInformationPicker.this.filter.getText()); } } @Override public void keyTyped(KeyEvent e) { } }); /** request focus in the filter window */ filter.requestFocusInWindow(); this.add(filter, new TableLayoutConstraints(1, 1, 3, 1)); itemList = new JList(listModel); itemList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); itemList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (itemList.getSelectedValue() != null) selectedEntity = (String) itemList.getSelectedValue(); } }); freeExpr = new JCheckBox(SpringLocaleDelegate.getInstance() .getMessageFromResource("wysiwg.metainformation.picker.freeexpr")); this.add(freeExpr, new TableLayoutConstraints(1, 2, 3, 2)); freeExpr.setVisible(true); // double click on item to select itemList.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { performSaveAction(); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }); filterItems(null); JScrollPane scrollpane = new JScrollPane(itemList); this.add(scrollpane, new TableLayoutConstraints(1, 4, 3, 4)); JButton apply = new JButton(BUTTON_LABELS.LABEL_APPLY); apply.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { performSaveAction(); } }); this.add(apply, new TableLayoutConstraints(1, 6)); JButton cancel = new JButton(BUTTON_LABELS.LABEL_CANCEL); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { performCancelAction(); } }); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { performCancelAction(); } }); this.add(cancel, new TableLayoutConstraints(3, 6)); this.setBounds(this.getBounds().x, this.getBounds().y, 300, 400); this.setTitle(TABLELAYOUT_PANEL.SELECT_FIELD_FOR_METAINFORMATION); this.setModal(true); }
From source file:org.executequery.gui.browser.FindAction.java
private JList initSearchResultsList() { final JList list = new JList(); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ListCellRenderer listCellRenderer = getListCellRenderer(); if (listCellRenderer != null) { list.setCellRenderer(listCellRenderer); }/*w ww . ja va2s. co m*/ list.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { listValueSelected((T) list.getSelectedValue()); } } }); list.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_ENTER) { listValueSelected((T) list.getSelectedValue()); } else if (keyCode == KeyEvent.VK_BACK_SPACE) { searchField.requestFocus(); } } }); return list; }