posted 16 years ago
Hi,
I have a problem in my application with focus handling. I am using a glass pane to prevent the user from interact with data while a lengthy process is running. So far, so good. However, if the process fails, I would like to display a warning dialog via JOptionPane.showMessageDialog.
My problem is, that the "Ok" button in the dialog is not focused. Pressing TAB works, but quite strangely: the button is focused, and if I reproduce the situation, the next time it is focused. Then it is not on the next time, etc.
Here is the code that sets the glass pane:
Initial settings for the glass pane:
How I use it before the long process runs:
The long process shows the message roughly like this:
It seems that the problem is the line getGlassPane().requestFocusInWindow(); But I have to give it the focus, so that the user cannot use the keys to meddle with the data when he should not.
How can I solve this problem?
Thanks,
David
[ May 03, 2007: Message edited by: David Nemeskey ]