This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Glasspane and JDialog" Watch "Glasspane and JDialog" New topic
Author

Glasspane and JDialog

ravikumar Chilukuri
Greenhorn

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
Bartender

Joined: Sep 20, 2010
Posts: 3605
    
  14

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.
ravikumar Chilukuri
Greenhorn

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....

Thanks.

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2157
    
    7
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
 
Similar Threads
Making JInternalFrame Modal
Making JDialog visible
modal in jdk1.3 & Win2000
popup
Glasspanes and tooltips