Topic: 怎么从文本框中取得数,并使得其值为DOUBLE型?

  Print this page

1.怎么从文本框中取得数,并使得其值为DOUBLE型? Copy to clipboard
Posted by: q_yuan
Posted on: 2004-11-19 20:36

请问各位高手。我想取得一个文本框里输入的数字,并把它转化为DOUBLE型,要用什么语句,或者用什么方法?
谢谢!

2.Re:怎么从文本框中取得数,并使得其值为DOUBLE型? [Re: q_yuan] Copy to clipboard
Posted by: littledeer1974
Posted on: 2004-11-19 20:46

是不是用这个呀
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.html#valueOf(java.lang.String)
public static double parseDouble(String s)
throws NumberFormatException


假设你的文本框是textField
那么,你也许可以这样

Double doubleyouwant;
String theString=new String(textField.getText());
doubleyouwant=Double.parseDouble(theString);


我没有测试,你可以试一下Smile


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923