tags:

views:

105

answers:

2

I am trying to have the user input a number, and then that number is used to populate a text field on a jform. However it keeps giving me errors. If I have the textfield call the str it gives me a numberformatexception, if I have it call the int variable it says it has to be a string...

public static String prePaidstr = "";
public static double prePaidint = 0;

prePaidstr = 
JOptionPane.showInputDialog("Enter any amount prepaid:");
prePaidint = Double.parseDouble(prePaidstr);

jTextField13.setText(InvoiceSelectionUI.prePaidstr)
+1  A: 

parseDouble converts a String into a Double, which is why it complains if you try to pass it a double.

A NumberFormatException is thrown when parseDouble is unable to successfully turn a String into a double; in this case it's because you're trying to parseDouble on an empty string. prePaidStr needs to contain something like "1.99" - e.g. something that, to a human, looks like a Double.

Matt Ball
A: 

nm - I fixed it, just had one of the variables switched around

Jason
Then mark the question as answered so people don't waste time reading the question.
camickr
cant accept your own answer for two days after posting.
Jason
If the question is no longer relevant, you can close it instead.
Matt Ball