aspose file tools*
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
Author

closing Simple message box

john black
Greenhorn

Joined: May 28, 2004
Posts: 1
hi,

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.

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

Brian


My Java Freeware:<br />MACCC - <a href="http://maccc.pipasoft.com" target="_blank" rel="nofollow">http://maccc.pipasoft.com</a><br />Nator - <a href="http://nator.pipasoft.com" target="_blank" rel="nofollow">http://nator.pipasoft.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: closing Simple message box