wood burning stoves
The moose likes Swing / AWT / SWT and the fly likes Glasspane and JDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Glasspane and JDialog" Watch "Glasspane and JDialog" New topic

Glasspane and JDialog

ravikumar Chilukuri

Joined: Sep 27, 2010
Posts: 14
I have a module suite project in which I am trying to find a way to "lock" my
application after a certain period of time. To accomplish this, I am using
the main window's glass pane to consume mouse and keyboard input. But when I
have a modal dialog open, the glass pane opens under the dialog. I know that
I could set the modal dialog's glass pane visible, but that is not quite
what I want - I need to display a painted glass pane over the entire main
window. Anyone know of a way to do this?
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4613

You should be able to do this using the Layered Pane, but what happens when the dialog is visible outside the bounds of the frame?

If you want to make your application unusable, it's probably best to indicate this in the way the GUI looks as well, otherwise it will seem the application has crashed. Simply disable the frame and the dialogs using setEnabled(false).

Another way you could do this is create a modal dialog, which says that the program has locked. If you close the modal dialog, you could make the entire application exit.

What is it exactly that you want to achieve, and why? There are several ways to do it, but some are more suitable than others.

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
ravikumar Chilukuri

Joined: Sep 27, 2010
Posts: 14
Hi Stephan
sorry for the late reply....

actually i miss-understood my projects requirement and trying the things in a wrong way........

my requirement is to display an animated glass pane which consumes all events for a certain period...
but the glasspane should be on top of dailogs also....
please suggest me a way to do achieve this....


Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2447
You can add a glass pane to a JFrame and you can add a glass pane to each JDialog.

You can't use a glass pane to cover all frames and dialogs.

But when I have a modal dialog open,

Then don't use a glass pane. Create another modal dialog, using the original dialog as the owner, then all events will be consumed by this dialog.
I agree. Here's the link: http://aspose.com/file-tools
subject: Glasspane and JDialog
It's not a secret anymore!