It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes closing Simple message box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "closing Simple message box " Watch "closing Simple message box " New topic

closing Simple message box

john black

Joined: May 28, 2004
Posts: 1

im am trying to put a time limit on how long a user has to press "ok" to message that has been displayed.

I have added a JOptionPane to a Jdialog to hopefully achieve this along with a java swing timer.

I am 99% sure there is nothing wrong with the way the timer is set up. There is something else thats wrong with the code but im not sure what. If someone could reply with the correct code to achieveing this whether or not the same way i tried below i would appreciate it.

Brian Pipa
Ranch Hand

Joined: Sep 29, 2003
Posts: 299
That's a tricky one. Took me a few minutes to figure it out. You have:

which calls the static method showMessageDialog(). Your pane object is still null and the dialog you see is not your pane JDialog, but one that was created by your static call. So...when you try and all dispose() it doesn't dispose the dialog that was created statically. Make sense? Try this instead:

and don't forget to pack before you setVisible():

that should get you going. Still some other thing you'll have to do to make it useable, but I'll leave that to you.


My Java Freeware:<br />MACCC - <a href="" target="_blank" rel="nofollow"></a><br />Nator - <a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: closing Simple message box
jQuery in Action, 3rd edition