Monday, February 28, 2011

How to set the focus to a component in java

Assume that you have a text field in your jFrame form and you want the cursor to set to that field after a button click.
If the name of your textField is "textField1" then use the following code as the button action.

textField1.requestFocusInWindow();

No comments:

Post a Comment