私のプログラムでは、誕生日の年齢ので動作します。私はJTextField文字列をdoubleに変換しようとするのに問題があります。解析メソッドを使用しましたが、引き続きエラーが発生しました。助けてください!は、どのように私は、二重にJTextFieldの文字列を変換するのですか?
public class MyPaymentFrame extends JFrame implements ActionListener {
JTextField txtAge;
JTextField txtDate;
public MyPaymentFrame() {
Container mycnt = getContentPane();
mycnt.setLayout(new FlowLayout());
Color c = new Color(56, 100, 20);
Font F = new Font("Arial", Font.ITALIC, 20);
mycnt.add(new JLabel("Enter your Age"));
txtAge = new JTextField(15);
mycnt.add(txtAmount);
mycnt.add(new JLabel("Enter birthdate"));
txtDate = new JTextField(10);
mycnt.add(txtDate);
}
if (e.getActionCommand().equals("Clear")) {
txtAge.setText("");
txtDate.setText("");
}
if (e.getActionCommand().equals("Calculate")) {
// Converting String to Double
double Amount = Double.parseDouble(txtMonth);
}
}
public static void main(String[] args) {
Theframe myframe = new Theframe();
}
}
あなたはどんなエラーを出していますか? – robotlos
あなたはトラブルシューティングするために、 'txtMonth'を印刷してみましたか...?それは最初の手順でなければなりません.... – Maljam
コードはコンパイルされません。 – null