Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

closing Simple message box

 
john black
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic