Reputation: 915
We can gain focus in any jComponent with grabFocus()
jtextField.grabGocus();
jlist.grabFocus();
jCombobox.grabFocus()
etc.
Upvotes: 0
Reputation: 808
All you need is to call grabFocus()
Example: jTextField.grabFocus();
Upvotes: 1
Reputation: 8677
requestFocus() can be used but is discouraged as it is platform dependent.
See here for more details
Upvotes: 3
Reputation: 5807
JTextField extends JComponent so JTextField would have this method.
Upvotes: 0
Reputation: 5076
The abstract class Component which JTextField extends provides a requestFocus() method.
JTextField jtf = getTextFieldFromSomewhere();
jtf.requestFocus();
Upvotes: 3