java界面输入如何取得浮点型?textfield是string,怎么转换?

来源:百度知道 编辑:UC知道 时间:2024/05/30 09:37:57
不好意思,没看太懂

Double.parseDouble(numberstring)
再强制类型转换
float number=(float)xxx

应该能用

取得浮点型需要使用强制转换;
textField中文本是以String的方式存储的,可以使用textField类对象的
getText()方法来检索,它返回一个字符串,如:
textField country=new textField("China",20);
String countryChioce=country.getText();