How do you set a focus on Textfield in Swing?

om. picture om. · Sep 15, 2009 · Viewed 77.8k times · Source

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 ?

Answer

phunehehe picture phunehehe · Sep 15, 2009

Would Component.requestFocus() give you what you need?