Alex Rivera | Logout

How do you set a focus on JTextField in Swing?

Asked 2009-09-15T06:03:37.130
50

I created a form using Swing in Java. In the form I have used a JTextField on which I have to set the focus whenever I press a key. How do I set focus on a particular component in Swing?

Edit
Report

1 Answer

16

Now that we've searched the API all we need to do is read the API.

According to the API documentation:

"Because the focus behavior of this method is platform-dependent, developers are strongly encouraged to use requestFocusInWindow when possible. "

answered 2009-09-15T22:07:16.237

Your Answer