Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Glasspane and JDialog

 
ravikumar Chilukuri
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 5589
54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2564
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic