import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class WindowSample implements ActionListener { TextField text1; TextField text2; //コンストラクタ中に画面設定を入れる WindowSample (){//@ //クラス名(部品の設計図) Frame //インスタンス名(実際の部品の名前) gamen //new 部品の新規作成 //Frame(); コンストラクタ関数を呼ぶ Frame gamen = new Frame("エクセル(嘘)"); //画面レイアウトを設定 FlowLayout flow = new FlowLayout(); gamen.setLayout(flow); text1 = new TextField(10); gamen.add(text1); text2 = new TextField(10); gamen.add(text2); Button bt1 = new Button("クリックしてね"); bt1.addActionListener(this);//このクラス内にアクション記述 gamen.add(bt1); Button bt2 = new Button("保存します"); gamen.add(bt2); gamen.setSize(600, 500); //横100、縦100設定 gamen.setVisible(true); //正しい=true } public static void main(String[] args) { WindowSample w = new WindowSample();//@に飛ぶ } //インターフェースのメソッドを具体化 public void actionPerformed(ActionEvent e) { //アクション text2.setText( text1.getText() ); } }