RequestFocusInWindow and multiple JPanel

W

willy

Hello,

First, I apologized for my bad english (I'm French ... )
Currently, I develop a Java software
And I have some problems with focus in Java:

I have a main JFrame and JPanel which are overlayed
In each JPanel, I have different JTextField.

I have a function that will give focus to a JTextField:
public static void myRequestFocusInWindow (final JTextField
field) (
SwingUtilities.invokeLater (new Runnable () (
public void run () (
field.requestFocusInWindow ();
)
));
)

But I noticed that when I was only 2 (or less) JPanel overlayed
the focus is correctly given.
but for more than 3 JPanel, the focus remains on the JTextField of the
2nd JPanel
which means that the focus is not given.

Unfortunately, I can not do without these JPanel
Therefore, I would like to know how to solve this.

I am afraid that we can not stack calls of SwingUtilities.invokeLater.

Please help me.
Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top