0

When I enter the username and the password I want to click the "Enter" button to login (I have to click Submit using the mouse.)

Do you know if there's something in the property on the button in NetBeans? what is it? If not please help me to fix the code.

Eric Wilson
  • 57,719
  • 77
  • 200
  • 270
Chris Sim
  • 4,054
  • 4
  • 29
  • 36

3 Answers3

2

In your form, try this: this.getRootPane().setDefaultButton(submitButton);

jasg
  • 182
  • 2
  • 10
0

In Netbeans, it works for buttons that I create from the code, but setDefaultButton() doesnt work for the buttons created by the GUI builder.

wattostudios
  • 8,666
  • 13
  • 43
  • 57
Ronin
  • 1
0

I would put a ketpressed event listener on the password field, then check the pressed key. If the key is the equals key, call your submit method. Make the submit button perform the same method, so they both perform the same method.

Logan
  • 2,369
  • 19
  • 20