• Post Reply Bookmark Topic Watch Topic
  • New Topic

data conversion still a problem

 
Tonia Billiot
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!