如何从 JTextField 中获取 Float 值?

How to take Float value from JTextField?

JTextField text=new JTextField();
text.gettext();

//我要text.gettext(); value 是一个浮点值来计算一个问题。如何把它当作??

要从文本字段中读取浮点数,您可以采用两种方法。

String a=text.getText();//Create a string to store the incoming data
float f = Float.parseFloat(a);// to cast the data

其他

float f = Float.parseFloat(text.getText);