Forums Register Login

about JOptionPane input values?

+Pie Number of slices to send: Send
i have a JOptionPane used for input of a numeric value...

like,




what if the user entered a String instead of a numeric value? how can i trace it? and put out another JOptionPane message dialog saying that the input is invalid?

+Pie Number of slices to send: Send
If you look at Integer#parseInt's API, what does it say when the parameter is not a parsable int ?
+Pie Number of slices to send: Send
 

Christophe Verré wrote:If you look at Integer#parseInt's API, what does it say when the parameter is not a parsable int ?



Nvm.. Thanks.
I got it now.
+Pie Number of slices to send: Send
You may be able to find a regular expression from the Integer API and use that to try validating the JOptionPane input. That might be quicker than awaiting an Exception. But you will still get problems if somebody enters 3000000000 for an int.
Quick! Before anybody notices! Cover it up 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 1331 times.
Similar Threads
JTable numeric validation
Why is request.getParameterValues not working for me?
Triangular Output
converting a double value
Inputbox
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:05:06.