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.emental.mindraider.ui.dialogs.ConnectUriqaServerJDialog.java
/** * Constructor.//ww w .j a v a2 s . com */ public ConnectUriqaServerJDialog() { super(Messages.getString("ConnectUriqaServerJDialog.title")); getContentPane().setLayout(new BorderLayout()); // north JPanel north = new JPanel(); north.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.serverUrl"))); uriqaServerUrl = new JTextField("http://sw.nokia.com/uriqa/", 31); uriqaServerUrl.setMinimumSize(new Dimension(TEXT_AREAS_WIDTH, uriqaServerUrl.getPreferredSize().height)); uriqaServerUrl.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { connect(); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); north.add(uriqaServerUrl); getContentPane().add(north, BorderLayout.NORTH); // center JPanel center = new JPanel(); center.setLayout(new BorderLayout()); JPanel centerTop = new JPanel(); centerTop.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.resource"))); String[] knowUriqaUris = new String[] { "http://sw.nokia.com/VOC-1/term", "http://sw.nokia.com/MARS-3/Rank", "http://sw.nokia.com/MARS-3", "http://sw.nokia.com/schemas/nokia/MARS-3.1.rdf" }; resourceUri = new JComboBox(knowUriqaUris); resourceUri.setMinimumSize(new Dimension(TEXT_AREAS_WIDTH, resourceUri.getPreferredSize().height)); resourceUri.setEditable(true); centerTop.add(resourceUri); JPanel centerCenter = new JPanel(); centerCenter.setLayout(new FlowLayout(FlowLayout.LEFT)); centerCenter.setToolTipText(Messages.getString("ConnectUriqaServerJDialog.loadOverToolTip")); centerCenter.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.loadOver"))); JCheckBox loadOver = new JCheckBox(); loadOver.setSelected(true); loadOver.setEnabled(false); centerCenter.add(loadOver); JPanel centerBottom = new JPanel(); centerBottom.setLayout(new FlowLayout(FlowLayout.LEFT)); centerBottom.setToolTipText(Messages.getString("ConnectUriqaServerJDialog.addInferedToolTip")); centerBottom.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.addInfered"))); addInfered = new JCheckBox(); addInfered.setSelected(true); centerBottom.add(addInfered); center.add(centerTop, BorderLayout.NORTH); center.add(centerCenter, BorderLayout.CENTER); center.add(centerBottom, BorderLayout.SOUTH); getContentPane().add(center, BorderLayout.CENTER); // south JPanel south = new JPanel(); JButton uploadButton = new JButton(Messages.getString("ConnectUriqaServerJDialog.connect")); uploadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { connect(); } }); south.add(uploadButton); JButton cancelButton = new JButton(Messages.getString("ConnectUriqaServerJDialog.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); south.add(cancelButton); getContentPane().add(south, BorderLayout.SOUTH); // show pack(); Gfx.centerAndShowWindow(this); }
From source file:MyButtonUI.java
public void keyPressed(KeyEvent e) { int code = e.getKeyCode(); if (code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE) { JComponent c = (JComponent) e.getComponent(); c.setBorder(m_borderLowered);/*from w w w. jav a 2s. co m*/ c.setBackground(m_backgroundPressed); } }
From source file:components.IntegerEditor.java
public IntegerEditor(int min, int max) { super(new JFormattedTextField()); ftf = (JFormattedTextField) getComponent(); minimum = new Integer(min); maximum = new Integer(max); //Set up the editor for the integer cells. integerFormat = NumberFormat.getIntegerInstance(); NumberFormatter intFormatter = new NumberFormatter(integerFormat); intFormatter.setFormat(integerFormat); intFormatter.setMinimum(minimum);// w w w . j a va 2 s. c o m intFormatter.setMaximum(maximum); ftf.setFormatterFactory(new DefaultFormatterFactory(intFormatter)); ftf.setValue(minimum); ftf.setHorizontalAlignment(JTextField.TRAILING); ftf.setFocusLostBehavior(JFormattedTextField.PERSIST); //React when the user presses Enter while the editor is //active. (Tab is handled as specified by //JFormattedTextField's focusLostBehavior property.) ftf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check"); ftf.getActionMap().put("check", new AbstractAction() { public void actionPerformed(ActionEvent e) { if (!ftf.isEditValid()) { //The text is invalid. if (userSaysRevert()) { //reverted ftf.postActionEvent(); //inform the editor } } else try { //The text is valid, ftf.commitEdit(); //so use it. ftf.postActionEvent(); //stop editing } catch (java.text.ParseException exc) { } } }); }
From source file:ve.zoonosis.controller.seguridad.NuevoUsuarioController.java
@Override public final void inicializar() { activeInput(false);//from ww w .j a v a 2 s .co m cardNumber.setEnabled(true); if (entity == null) { entity = new Usuario(); limpiar(); buscar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { buscarPersona(); } }); limpiar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { limpiar(); } }); cardNumber.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { buscar.setEnabled(validarCedula()); if (e.getKeyCode() == KeyEvent.VK_ENTER && buscar.isEnabled()) { buscarPersona(); } } }); } else { activeInput(true); persona = entity.getPersona(); permiso.setEnabled(false); buscar.setVisible(false); limpiar.setVisible(false); BindObject bindObject2 = new BindObject(persona); Bindings.bind(cardNumber, bindObject2.getBind("cedula")); Bindings.bind(nombre, bindObject2.getBind("nombre")); Bindings.bind(apellido, bindObject2.getBind("apellido")); } aceptar.setEnabled(false); nombre.setMaxLength(45); apellido.setMaxLength(45); cardNumber.setMaxLength(20); usr.setMaxLength(20); iniForm(); try { rb = new RequestBuilder("services/administracion/PermisoWs/BuscarPermiso.php"); List<Permiso> permisos = rb.ejecutarJson(List.class, Permiso.class); if (permisos != null) { permisos.add(0, null); permiso.setModel(new ListComboBoxModel<>(permisos)); permiso.setSelectedIndex(-1); } } catch (URISyntaxException | RuntimeException ex) { LOG.LOGGER.log(Level.SEVERE, null, ex); } BindObject bindObject2 = new BindObject(entity); Bindings.bind(usr, bindObject2.getBind("nombre")); Bindings.bind(contrasena, bindObject2.getBind("contrasena")); Bindings.bind(fechaNacimiento, bindObject2.getBind("fechaNacimiento"), new SimpleDateFormat("dd/MM/yyyy")); Bindings.bind(permiso, bindObject2.getBind("permiso"), true); autoCreateValidateForm(Persona.class, Usuario.class); repeatPass.addKeyListener(formularioActionListener); usr.addKeyListener(formularioActionListener); DateTime d = new DateTime(); Date dia = new Date(d.getDayOfMonth() + "/" + d.getMonthOfYear() + "/" + (d.getYear() - 18)); fechaNacimiento.setMaxSelectableDate(dia); Date dia2 = new Date(d.getDayOfMonth() + "/" + d.getMonthOfYear() + "/" + (d.getYear() - 80)); fechaNacimiento.setMinSelectableDate(dia2); iniciarDialogo(); }
From source file:ve.zoonosis.controller.seguridad.LoginController.java
private void iniciarSesion(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ENTER) { evt.consume(); iniciarSesion(); } }
From source file:org.apache.cayenne.modeler.util.PathChooserComboBoxCellEditor.java
protected void initializeCombo(CayenneTableModel model, int row, final JTable table) { Object currentNode = getCurrentNodeToInitializeCombo(model, row); String dbAttributePath = getPathToInitializeCombo(model, row); List<String> nodeChildren = getChildren(currentNode, dbAttributePath); this.table = table; comboBoxPathChooser = Application.getWidgetFactory().createComboBox(nodeChildren, false); comboBoxPathChooser.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { @Override//from w ww . j a v a2 s .c om public void keyReleased(KeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_ENTER) { enterPressed(table); return; } parsePathString(event.getKeyChar()); } }); AutoCompletion.enable(comboBoxPathChooser, true, true); ((JComponent) comboBoxPathChooser.getEditor().getEditorComponent()).setBorder(null); comboBoxPathChooser.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); comboBoxPathChooser.setRenderer(new PathChooserComboBoxCellRenderer()); comboBoxPathChooser.addActionListener(this); comboBoxPathChooser.addPopupMenuListener(this); }
From source file:com.emental.mindraider.ui.dialogs.AddTripletJDialog.java
/** * Constructor./*from ww w . j a v a2s. com*/ */ public AddTripletJDialog() { super("Add Triplet"); JPanel framePanel = new JPanel(); framePanel.setLayout(new GridLayout(4, 1)); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(new JLabel(" Predicate: ")); predicateNs = new JTextField(30); predicateNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS); predicateNs.selectAll(); p.add(predicateNs); p.add(new JLabel("#")); predicateLocalName = new JTextField(15); p.add(predicateLocalName); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(new JLabel(" Object: ")); objectNs = new JTextField(30); objectNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS); objectNs.selectAll(); p.add(objectNs); p.add(new JLabel("#")); objectLocalName = new JTextField(15); objectLocalName.grabFocus(); objectLocalName.selectAll(); objectLocalName.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { createTriplet(); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); p.add(objectLocalName); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); literalCheckBox = new JCheckBox("literal", false); p.add(literalCheckBox); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton addButton = new JButton("Add"); p.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createTriplet(); } }); JButton cancelButton = new JButton("Cancel"); p.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AddTripletJDialog.this.dispose(); } }); framePanel.add(p); getContentPane().add(framePanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { getObjectLocalName().requestFocusInWindow(); } }); }
From source file:MyButtonUI.java
public void keyReleased(KeyEvent e) { int code = e.getKeyCode(); if (code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE) { JComponent c = (JComponent) e.getComponent(); c.setBorder(m_borderRaised);//from ww w .j a va 2 s .com c.setBackground(m_backgroundNormal); } }
From source file:com.tascape.qa.th.android.tools.UiAutomatorViewer.java
private void start() throws Exception { SwingUtilities.invokeLater(() -> { jd = new ViewerParameterDialog("Launch Android App"); JPanel jpParameters = new JPanel(); jpParameters.setLayout(new BoxLayout(jpParameters, BoxLayout.PAGE_AXIS)); jd.setParameterPanel(jpParameters); {//from w w w .j a v a 2s.c o m JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(new JLabel("Devices")); jp.add(jcbDevices); } { JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(new JLabel("App Package Name")); jp.add(jtfApp); if (StringUtils.isNotEmpty(appPackageName)) { jtfApp.setText(appPackageName); } jtfApp.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { jbLaunch.doClick(); } } }); } { JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(new JLabel("Interaction time (minute)")); jsDebugMinutes.getEditor().setEnabled(false); jp.add(jsDebugMinutes); } { JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(Box.createRigidArea(new Dimension(518, 2))); } JPanel jpAction = new JPanel(); jd.setActionPanel(jpAction); jpAction.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS)); jbLaunch.setFont(jbLaunch.getFont().deriveFont(Font.BOLD)); jbLaunch.setBorder(BorderFactory.createEtchedBorder()); jbLaunch.setEnabled(false); jpAction.add(jbLaunch); jbLaunch.addActionListener(event -> { new Thread() { @Override public void run() { launchApp(); } }.start(); }); jd.showDialog(); new Thread() { @Override public void run() { try { detectDevices(); } catch (Exception ex) { throw new RuntimeException(ex); } } }.start(); }); }
From source file:ve.zoonosis.controller.modulos.novdedades.NuevoClienteController.java
@Override public final void inicializar() { activeInput(false);//from w ww . j a v a 2 s. c o m cardNumber.setEnabled(true); buscar.setEnabled(false); if (entity == null) { entity = new Cliente(); } limpiar(); iniForm(); buscar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { buscarPersona(); } }); limpiar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { limpiar(); } }); telefono.addKeyListener(formularioActionListener); cardNumber.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { buscar.setEnabled(validarCedula()); if (e.getKeyCode() == KeyEvent.VK_ENTER && buscar.isEnabled()) { buscarPersona(); } } }); BindObject bindObject2 = new BindObject(entity); Bindings.bind(correo, bindObject2.getBind("correo")); Bindings.bind(direccion, bindObject2.getBind("direccion")); Bindings.bind(telefono, bindObject2.getBind("telefono")); Bindings.bind(parroquia, bindObject2.getBind("parroquia"), true); nombre.setMaxLength(45); apellido.setMaxLength(45); cardNumber.setMaxLength(20); correo.setMaxLength(45); telefono.setMaxLength(12); direccion.setMaxLength(200); try { rb = new RequestBuilder("services/administracion/MunicipioWs/ListaMunicipios.php"); List<Municipio> municipios = rb.ejecutarJson(List.class, Municipio.class); if (municipios != null) { municipios.add(0, null); municipio.setModel(new ListComboBoxModel<>(municipios)); municipio.setSelectedIndex(-1); } } catch (URISyntaxException | RuntimeException ex) { LOG.LOGGER.log(Level.SEVERE, null, ex); } municipio.addActionListener(new MunicipioListener(parroquia)); parroquia.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { entity.setParroquia((Parroquia) parroquia.getSelectedItem()); aceptar.setEnabled(validar()); } }); autoCreateValidateForm(Persona.class, Cliente.class); iniciarDialogo(); cardNumber.requestFocus(); }