を使用して、メートルのユーザー入力をフィートとインチに変換します。
// following format (16ft. 4in.). Disable the button so that
// the user is forced to clear the form.
問題は、文字列と int 値の両方を 1 つのテキスト フィールドに入れる方法がわからないことです。 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");
}
}
string と int 値の両方を 1 つに追加することは可能JTextField
ですか?