package applet; import java.applet.Applet; import java.awt.Button; import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class RensyuGamen extends Applet implements ActionListener{ TextField tf; TextField tf2; //クリックイベント発生源 Button bt; public void init(){ tf = new TextField(10); add(tf); tf2 = new TextField(10); add(tf2); bt = new Button("ボタン"); add(bt); //関連付け bt.addActionListener(this); }//init() @Override public void actionPerformed(ActionEvent e) { //入力テキストの取り出し String input = tf.getText(); //値の整数化 int num = Integer.parseInt(input); //Double.parseDouble(input); //値のクリア(無文字をセット) tf.setText(""); //テキストのセット tf2.setText(input); System.out.println ("クリック"); } }