• 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

data conversion still a problem

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JTextField is on panel two. The user should enter their total gross sales. I need to convert it to perform tax calculations and insert the total to panel three.
txtGrsTot is the JTextField where the user types some dollar amount. I am able to type in an amount; however, nothing is done w/ the amount.


I've also attempted: Double tmpValue = Double.ValueOf(txtGrsTot)
double value = tmpValue.doubleValue();
and one other conversion method that I don't remember at this time; however, all three gave the same error message.. Can someone tell me what I'm doing wrong?

Error Message:
Exception in thread "main" java.lang.NumberFormatException: empty String
at java.lang.FloatingDecimal.readJavaFormatString(Unknown Source)
at java.lang.Double.parseDouble(Unknown Source)
at SalesTaxWizard.useCardMethod(SalesTaxWizard.java:153)
at SalesTaxWizard.main(SalesTaxWizard.java:12)

I have done something similar w/ JOptionPane in the past, but this seems to be very different. I appreciate all assistance.
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your conversion methods are fine; the problem must be the text field. First things first, make sure of that. Print out the result of txtGrsTot.getText() and see if it's what you typed. I suspect it's empty, and parseDouble() doesn't like an empty String.

Perhaps you're referencing the wrong JTextField? Did you overwrite the reference when creating the other text fields?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic