将用户输入的米转换为英尺和英寸
// following format (16ft. 4in.). Disable the button so that
// the user is forced to clear the form.
问题是我不知道如何将字符串和 int 值放在一个文本字段中,而不是如何在 if else 语句中设置它们
private void ConversionActionPerformed(ActionEvent e )
{
String s =(FourthTextField.getText());
int val = Integer.parseInt(FifthTextField.getText());
double INCHES = 0.0254001;
double FEET = 0.3048;
double meters;
if(s.equals("in" ) )
{
FourthTextField.setText(" " + val*INCHES + "inch");
}
else if(s.equals("ft"))
{
FourthTextField.setText(" " +val*FEET + "feet");
}
}
是否可以同时添加字符串和 int 值JTextField
?