Forums Register Login

JOptionPane: action on cancel for Input dialog

+Pie Number of slices to send: Send
I am using JOptionPane.showInputDialog() to get an input value. It is having OK, cancel button. Is there any way, I can know cancel button is pressed, since i want to perform some actions when cancel is pressed.

Again, when close on right top corner is pressed, Is there any way, I can know close is pressed.
+Pie Number of slices to send: Send
Have you read the API? Because the answer is right there, in the showInputDialog with the most parameters:

Returns:
user's input, or null meaning the user canceled the input


That also includes pressing the close button; only if OK was pressed will the returned value not be null.
+Pie Number of slices to send: Send
Thanks.
Don't MAKE me come back there with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 7896 times.
Similar Threads
How to override the window.close() event
Using InputVerifier
major problem with html:cancel and html:submit
JOptionpane
validation problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:25:01.