I have a screen in which I have used flow layout, and in this screen there are two components 1. JComboBox and 2. JtextField.
Now the problem is JCombobox is first component and after that jTextField is displayed, Now I have used below method to setFocus as the screen starts. But it is not working...
But still Combobox is getting focused as we start the screen. What I have analyzed is that it might be because, JCombobox is itself is Component. Can any body help me, how can I getFocus on TextField.
The Best way to predict your future is to create it
Ankur Sharma
if so, use a timer for the requestFocusInWindow(), 250ms should do
Ankur Sharma
Ranch Hand
Joined: Dec 27, 2005
Posts: 1234
posted
0
Originally posted by Michael Dunn: is this in a JTabbedPane?
if so, use a timer for the requestFocusInWindow(), 250ms should do
No it's not JTabbedPane....... and even it's not working If I am using requestFocusInWindow().
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
requestFocusInWindow() must be called after the frame is visible, so invokeLater should work.
try setting frame.setVisible(true) before the SwingUtilities, if still not working post a short demo program, so we can see how you have put it together.