Search code examples
javaswingjtextfield

java 8 neatbeans 8.0.2 swing component jTextfield


I am working with Java 8 and NetBeans 8.0.2.

I can't insert a private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) method by right clicking into the jTextField.

This is to complete a okBtnActionPerformed(java.awt.event.ActionEvent evt) method. It is to allow user to put a data using the "return key" instead of "OK button".


Solution

  • It is to allow user to put a data using the "return key" instead of "OK button"

    Then you can add an ActionListener to the text field. More specifically you can add the same ActionListener that you add to the OK button. Then the user can either click on the button or use the Enter key when focus is on the text field.