i am creating a simple program to get input from user and do calculation....
Am using netbeans... when i try to get input from textfield am getting numberformatexception..
There is a possiblity of an NumberFormatException. It depends that the text of the field was.
I think you should be able to solve it with this code:
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Shouldn't You use getValue() instead of getText() ?? It always returns valid value and getText may not... also use JFormattedTextField(Object value) constructor to create first valid value and setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0")))); to get integers only.
Climb the rope! CLIMB THE ROPE! You too tiny ad:
a bit of art, as a gift, that will fit in a stocking