• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Focus problem: glasspane + dialog

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic