Discussion:
can jtextfield display float or double data type?
sadsad_story
2012-10-06 10:36:12 UTC
Permalink
do anyone know how to save float or double data type in textfield?

below is my coding to do calculation:
double userKeyin = Double.parseDouble(txtPay.getText());
double Total = Double.parseDouble(txtTotal.getText());
String Change = String.valueOf(userKeyin - Total);
jTextField1.setText(""+Change);

when i key in 60, 70, 80 to minus float data type, the output will be 000000003 or 9999999997 something like this...

anyone can help me pls.... :(
Edson Richter
2012-10-07 13:52:01 UTC
Permalink
Post by sadsad_story
do anyone know how to save float or double data type in textfield?
double userKeyin = Double.parseDouble(txtPay.getText());
double Total = Double.parseDouble(txtTotal.getText());
String Change = String.valueOf(userKeyin - Total);
jTextField1.setText(""+Change);
when i key in 60, 70, 80 to minus float data type, the output will be 000000003 or 9999999997 something like this...
anyone can help me pls.... :(
Sure, this is a Java issue. Check here:
http://docs.oracle.com/javase/tutorial/java/data/numberformat.html

Regards,

Edson
Continue reading on narkive:
Search results for 'can jtextfield display float or double data type?' (Questions and Answers)
4
replies
URGENT!! please answer these adv java please!!?
started 2012-10-06 08:04:12 UTC
programming & design
Loading...