Skip to main content

Posts

Showing posts with the label Netbeans

Java NetBeans : submit button not working when press Enter?

Today, I noticed that my form is not getting submitted while using keyboard Enter button to submit it. Then I searched over that and found different solutions and sharing them with you : 1) If your form is only having one button and that’s only submit button then use the      following line in your code: this.getRootPane().setDefaultButton(submitButton); I have used this line in constructor. It would work and your submit button will be automatically get focused. 2) If you have more than one button, as in my case there are three buttons, above solution will not work. Because, on any given Window a single button can be designated as the “Default Button”. The default button is noticeable by the darker border around the button. The default button can be activated by using the Enter key, even when it doesn’t have focus. When your focus is on another button and you press enter even then only submit button is working not the one you have ...