| Author |
how to getInt
|
wong chang kit
Greenhorn
Joined: May 15, 2012
Posts: 20
|
|
|
 |
wong chang kit
Greenhorn
Joined: May 15, 2012
Posts: 20
|
|
Hi guys.
After I added in my code.
I got an error. Saying that
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "2,000"
Anyone knows how to solve it?
|
 |
Randall Twede
Ranch Hand
Joined: Oct 21, 2000
Posts: 4089
|
|
|
"2,000" can't be changed to a number. "2000" can
|
SCJP
|
 |
wong chang kit
Greenhorn
Joined: May 15, 2012
Posts: 20
|
|
But the thing is that I'm using
The format is fixed. Whatever numbers that I typed in. It will automatically change to 2,000 with the comma .
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4163
|
|
wong chang kit wrote:in my code.
I got an error. Saying that
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "2,000"
In the code you didn't post?
To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.
Before that, read the API for JFormattedTextField and make sure you're using the correct method to obtain the value.
|
luck, db
There are no new questions, but there may be new answers.
|
 |
wong chang kit
Greenhorn
Joined: May 15, 2012
Posts: 20
|
|
Anyone knows how to remove the comma between "2,000"
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "2,000"
by the way, I'm using JTextField Value = new JFormattedTextField(NumberFormat.getInstance());
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19214
|
|
|
You obviously haven't followed Darryl's advice to read the Javadoc, because there is a method to get the value of the field.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
wong chang kit
Greenhorn
Joined: May 15, 2012
Posts: 20
|
|
|
I did..but I could not get what I'm looking in the website.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19214
|
|
I'll say it again: can you find a method with which you can get the Value?
Note that that method does not need to return an int; JFormattedTextField is a bit more generic (not with <T> though) than just for numbers, it can also be used for anything that can be formatted (like dates). You will have to check what the actual class of the object is, and then retrieve an int from that.
|
 |
 |
|
|
subject: how to getInt
|
|
|