aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to getInt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to getInt" Watch "how to getInt" New topic
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: 4347
    
    2

"2,000" can't be changed to a number. "2000" can


SCJP
Visit my download page
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: 4664
    
    5

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: 19785
    
  20

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 - OCEEJBD 6
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: 19785
    
  20

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to getInt