• Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane closing  RSS feed

 
Mahesh x Bogadi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am developing a network management system.
We show the warning and error messages using JOptionPane.

So my question is :
How to close any JOptionPane pop-up showing when the applicatin gets disconnected?

Is there any way through which we can close all the opened JOptionPane instances?

Please help.
 
Tom McC
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if there's a way to go through and close all JOptionPanes, but another option (no pun intended =) would be to make your own class that extends JDialog that does the same things you need to get done with JOptionPane. You could then access all your dialogs directly and hide them at will.

It's a little pesky, I'll admit, but we'll see if anybody else has a better answer.
[ August 04, 2005: Message edited by: Tom McC ]
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's really safe to just kill all JOptionPanes you can do something like this:



This is not a very clean solution, but it may be good enough for your needs.
 
Mahesh x Bogadi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry. This doest not work
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're probably passing a non-null argument for the parent frame when creating the JOptionPane. The idea behind this hack is to exploit the fact that when a frame is disposed, all windows it "owns" are disposed too. Thus it's critical that you actually dispose a frame that owns the JOptionPane. Certainly you could make a slightly modified version of the hack work more generally, but at that point you're better off using new JOptionPane().createDialog() and recording the JDialog for later disposal.
 
Swetha pradha
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,

Having a similar problem . I need to close all the open JOptionPanes which the user has not clicked . Kindly post a solution if available

Thanks in advance
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!