Hello, I have created one form using Swing in Java.In the form I have used one textfield on which I have to set the focus whenever I press the key.How to set focus on a particular component in Java ?
+4
A:
Hi there,
Just a simple search through the API would give you Component.requestFocus(), is that what you need?
phunehehe
2009-09-15 06:07:37
Thanks,let me see whether it works for me or not
om
2009-09-15 06:10:36
Took me five minutes to find it ... so much for "simple" search :-( – ah well, the Java API docs aren't a paragon of clarity anyway :-)
Joey
2009-09-15 06:12:48
A:
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. "
camickr
2009-09-15 22:07:16