In this tutorial we use Enter function to accept a button event, for example in log-in formwhen I press the Enter key the system perform the log-in event and no need to use your mouse and click the log-in button. Please follow the instruction below.
Copy the code below and insert in your public class or form load event like image below. Focus on the highlighted part of the code. The jButton1 is the button we perform the event. When you press Enter in the keyboard the jButton1 perform the event.
Copy the code below and insert in your public class or form load event like image below. Focus on the highlighted part of the code. The jButton1 is the button we perform the event. When you press Enter in the keyboard the jButton1 perform the event.
Just copy the code below and modify on your own needs.
this.getRootPane().setDefaultButton(jButton1);
0 Comments