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.
posted 11 years ago
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.