• Post Reply Bookmark Topic Watch Topic
  • New Topic

Focus problem: glasspane + dialog  RSS feed

 
David Nemeskey
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Darrin Cartwright
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

This is just a wild guess, but have you tried not specifying a parent component (using null) for the JOptionPane? Change your call to look like this:



Any luck?

Darrin
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!