List of usage examples for java.awt.event KeyEvent consume
public void consume()
From source file:com.mirth.connect.client.ui.components.KeyStrokeTextField.java
@Override public void keyPressed(KeyEvent evt) { if (keyCode != null && (evt.getKeyCode() == KeyEvent.VK_ENTER || evt.getKeyCode() == KeyEvent.VK_ESCAPE)) { return;//from w w w . j a v a 2 s . c o m } if (keyCode == null && evt.getKeyCode() > 0 && !ArrayUtils.contains(ignoreKeyCodes, evt.getKeyCode())) { int index = ArrayUtils.indexOf(modifierKeyCodes, evt.getKeyCode()); if (index >= 0) { modifiers |= modifierMasks[index]; } else { keyCode = evt.getKeyCode(); } updateKeyStroke(); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } evt.consume(); }
From source file:interfazGrafica.frmMoverRFC.java
private void txtCapturaCurpKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCapturaCurpKeyTyped char caracter = evt.getKeyChar(); if (Character.isDigit(caracter) || Character.isLetter(caracter)) { String texto = txtCapturaCurp.getText() + caracter; txtCapturaCurp.setText(texto.toUpperCase()); evt.consume(); this.repaint(); } else {//w w w . jav a2 s .c om getToolkit().beep(); evt.consume(); } }
From source file:pipeline.parameter_cell_views.TextBox.java
public TextBox() { super();/*from w w w . java 2s. c o m*/ setLayout(new GridBagLayout()); parameterName = new JLabel(""); textField = new JTextArea(currentValue); textField.getDocument().addDocumentListener(new valueListener()); // textField.setMinimumSize(new Dimension(150,40)); textField.setLineWrap(true); textField.addMouseListener(this); textField.addKeyListener(new KeyAdapter() { // from http://www.java.net/node/650657 @Override public void keyPressed(KeyEvent evt) { int iKey = evt.getKeyCode(); JComponent component = (JTextArea) evt.getComponent(); DefaultFocusManager focusManager = new DefaultFocusManager(); if ((iKey == KeyEvent.VK_ENTER) || // (iKey == KeyEvent.VK_DOWN) || (iKey == KeyEvent.VK_PAGE_UP) || (iKey == KeyEvent.VK_PAGE_DOWN) || (iKey == KeyEvent.VK_TAB)) { evt.consume(); focusManager.focusNextComponent(component); } // if (iKey == KeyEvent.VK_UP) // focusManager.focusPreviousComponent(component); } }); c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridheight = 2; c.weighty = 1.0; c.weightx = 1.0; c.gridwidth = 1; scrollPane = new JScrollPane(textField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); add(scrollPane, c); scrollPane.setPreferredSize(new Dimension(1000, 500)); scrollPane.setMinimumSize(new Dimension(10, 60)); c.weighty = 0; add(parameterName, c); parameterNameAdded = true; parameterName.setMinimumSize(new Dimension(100, 30)); }
From source file:com.googlecode.vfsjfilechooser2.accessories.connection.ConnectionDialog.java
private void initListeners() { this.portTextField.addKeyListener(new KeyAdapter() { @Override//w w w. j a v a 2s. c o m public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (!((Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)))) { getToolkit().beep(); e.consume(); } else { setPortTextFieldDirty(true); } } }); this.portTextField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { JFormattedTextField f = (JFormattedTextField) e.getSource(); String text = f.getText(); if (text.length() == 0) { f.setValue(null); } try { f.commitEdit(); } catch (ParseException exc) { } } }); this.cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (currentWorker != null) { if (currentWorker.isAlive()) { currentWorker.interrupt(); setCursor(Cursor.getDefaultCursor()); } } setVisible(false); } }); this.connectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { currentWorker = new Thread() { @Override public void run() { StringBuilder error = new StringBuilder(); FileObject fo = null; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try { String m_username = usernameTextField.getText(); String m_defaultRemotePath = defaultRemotePathTextField.getText(); char[] m_password = passwordTextField.getPassword(); String m_hostname = hostnameTextField.getText(); String m_protocol = protocolList.getSelectedItem().toString(); int m_port = -1; if (portTextField.isEditValid() && (portTextField.getValue() != null)) { String s = portTextField.getValue().toString(); m_port = Integer.valueOf(s); } Builder credentialsBuilder = Credentials.newBuilder(m_hostname) .defaultRemotePath(m_defaultRemotePath).username(m_username) .password(m_password).protocol(m_protocol).port(m_port); Credentials credentials = credentialsBuilder.build(); String uri = credentials.toFileObjectURL(); if (isInterrupted()) { setPortTextFieldDirty(false); return; } fo = VFSUtils.resolveFileObject(uri); if ((fo != null) && !fo.exists()) { fo = null; } } catch (Exception err) { error.append(err.getMessage()); setCursor(Cursor.getDefaultCursor()); } if ((error.length() > 0) || (fo == null)) { error.delete(0, error.length()); error.append("Failed to connect!"); error.append("\n"); error.append("Please check parameters and try again."); JOptionPane.showMessageDialog(ConnectionDialog.this, error, "Error", JOptionPane.ERROR_MESSAGE); setCursor(Cursor.getDefaultCursor()); return; } if (isInterrupted()) { return; } fileChooser.setCurrentDirectoryObject(fo); setCursor(Cursor.getDefaultCursor()); resetFields(); if (bookmarksDialog != null) { String bTitle = fo.getName().getBaseName(); if (bTitle.trim().equals("")) { bTitle = fo.getName().toString(); } String bURL = fo.getName().getURI(); bookmarksDialog.getBookmarks().add(new TitledURLEntry(bTitle, bURL)); bookmarksDialog.getBookmarks().save(); } setVisible(false); } }; currentWorker.setPriority(Thread.MIN_PRIORITY); currentWorker.start(); } }); // add the usual right click popup menu(copy, paste, etc.) PopupHandler.installDefaultMouseListener(hostnameTextField); PopupHandler.installDefaultMouseListener(portTextField); PopupHandler.installDefaultMouseListener(usernameTextField); PopupHandler.installDefaultMouseListener(passwordTextField); PopupHandler.installDefaultMouseListener(defaultRemotePathTextField); this.protocolList.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { selectPortNumber(); } } }); this.protocolList.setSelectedItem(Protocol.FTP); }
From source file:net.sf.vfsjfilechooser.accessories.connection.ConnectionDialog.java
private void initListeners() { this.portTextField.addKeyListener(new KeyAdapter() { @Override/* w w w. j a va2 s . co m*/ public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (!((Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)))) { getToolkit().beep(); e.consume(); } else { setPortTextFieldDirty(true); } } }); this.portTextField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { JFormattedTextField f = (JFormattedTextField) e.getSource(); String text = f.getText(); if (text.length() == 0) { f.setValue(null); } try { f.commitEdit(); } catch (ParseException exc) { } } }); this.cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (currentWorker != null) { if (currentWorker.isAlive()) { currentWorker.interrupt(); setCursor(Cursor.getDefaultCursor()); } } setVisible(false); } }); this.connectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { currentWorker = new Thread() { @Override public void run() { StringBuilder error = new StringBuilder(); FileObject fo = null; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try { String m_username = usernameTextField.getText(); String m_defaultRemotePath = defaultRemotePathTextField.getText(); char[] m_password = passwordTextField.getPassword(); String m_hostname = hostnameTextField.getText(); String m_protocol = protocolList.getSelectedItem().toString(); int m_port = -1; if (portTextField.isEditValid() && (portTextField.getValue() != null)) { String s = portTextField.getValue().toString(); m_port = Integer.valueOf(s); } Builder credentialsBuilder = Credentials.newBuilder(m_hostname) .defaultRemotePath(m_defaultRemotePath).username(m_username) .password(m_password).protocol(m_protocol).port(m_port); Credentials credentials = credentialsBuilder.build(); String uri = credentials.toFileObjectURL(); if (isInterrupted()) { setPortTextFieldDirty(false); return; } fo = VFSUtils.resolveFileObject(uri); if ((fo != null) && !fo.exists()) { fo = null; } } catch (Exception err) { error.append(err.getMessage()); setCursor(Cursor.getDefaultCursor()); } if ((error.length() > 0) || (fo == null)) { error.delete(0, error.length()); error.append("Failed to connect!"); error.append("\n"); error.append("Please check parameters and try again."); JOptionPane.showMessageDialog(ConnectionDialog.this, error, "Error", JOptionPane.ERROR_MESSAGE); setCursor(Cursor.getDefaultCursor()); return; } if (isInterrupted()) { return; } fileChooser.setCurrentDirectory(fo); setCursor(Cursor.getDefaultCursor()); resetFields(); if (bookmarksDialog != null) { String bTitle = fo.getName().getBaseName(); if (bTitle.trim().equals("")) { bTitle = fo.getName().toString(); } String bURL = fo.getName().getURI(); bookmarksDialog.getBookmarks().add(new TitledURLEntry(bTitle, bURL)); bookmarksDialog.getBookmarks().save(); } setVisible(false); } }; currentWorker.setPriority(Thread.MIN_PRIORITY); currentWorker.start(); } }); // add the usual right click popup menu(copy, paste, etc.) PopupHandler.installDefaultMouseListener(hostnameTextField); PopupHandler.installDefaultMouseListener(portTextField); PopupHandler.installDefaultMouseListener(usernameTextField); PopupHandler.installDefaultMouseListener(passwordTextField); PopupHandler.installDefaultMouseListener(defaultRemotePathTextField); this.protocolList.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { selectPortNumber(); } } }); this.protocolList.setSelectedItem(Protocol.FTP); }
From source file:vistas.ModPersonal.java
private void txt_NameMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_NameMKeyTyped char car = evt.getKeyChar(); if ((car < 'a' || car > 'z') && (car < 'A' || car > 'Z') && (car != (char) KeyEvent.VK_SPACE) && (car != (char) KeyEvent.VK_BACK_SPACE)) { JOptionPane.showMessageDialog(this, "Ingrese solo letras"); evt.consume(); }// w ww . j av a2 s . c om }
From source file:vistas.ModPersonal.java
private void txt_apellidoMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_apellidoMKeyTyped char car = evt.getKeyChar(); if ((car < 'a' || car > 'z') && (car < 'A' || car > 'Z') && (car != (char) KeyEvent.VK_SPACE) && (car != (char) KeyEvent.VK_BACK_SPACE)) { JOptionPane.showMessageDialog(this, "Ingrese solo letras"); evt.consume(); }//from w w w. j a v a 2 s.co m }
From source file:schoolsystem.FeeModule.java
private void txt_fee_module_receiptKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_fee_module_receiptKeyTyped if (evt.getKeyChar() < '0' || evt.getKeyChar() > '9') { Toolkit.getDefaultToolkit().beep(); evt.consume(); }//from ww w.j av a2 s . com }
From source file:schoolsystem.FeeModule.java
private void txt_fee_module_cheque_noKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_fee_module_cheque_noKeyTyped if (evt.getKeyChar() < '0' || evt.getKeyChar() > '9') { Toolkit.getDefaultToolkit().beep(); evt.consume(); } // TODO add your handling code here: }
From source file:schoolsystem.FeePanel.java
private void txt_fee_moduleKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_fee_moduleKeyTyped if (evt.getKeyChar() >= '0' && evt.getKeyChar() <= '9') { } else {/*from ww w . jav a 2 s.co m*/ if (evt.getKeyChar() == KeyEvent.VK_SLASH) { } else { evt.consume(); Toolkit.getDefaultToolkit().beep(); } } // TODO add your handling }