• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to getInt

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



 
wong chang kit
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"2,000" can't be changed to a number. "2000" can
 
wong chang kit
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
wong chang kit
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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());
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You obviously haven't followed Darryl's advice to read the Javadoc, because there is a method to get the value of the field.
 
wong chang kit
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did..but I could not get what I'm looking in the website.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic