import java.awt.*; import java.awt.event.*; public class Test { public static void main (String[] args) { Win win = new Win("Test Window"); } } class Win extends Frame { Win (String name) { // Frameクラスのコンストラクタ(Windowのタイトルを引き渡す) super(name); // Windowの大きさ setSize(400, 300); // レイアウトの変更(位置) setLayout(new FlowLayout(FlowLayout.CENTER)); // テキストフィールド設定 TextField text_f = new TextField("Text Field"); add(text_f); // テキストエリア設定 TextArea text_a = new TextArea("Text Area", 10, 30); add(text_a); // ラベルの設定 Label lb = new Label("FlowLayout"); add(lb); // ボタンの設定 Button bt1 = new Button("OK"); add(bt1); // ウィンドウを表示 setVisible(true); // イベントアダプタ addWindowListener(new WinEnd()); } /******************************/ /* 上,左,下,右の余白の設定 */ /******************************/ public Insets getInsets() { return new Insets(35, 10, 10, 10); } /************/ /* 終了処理 */ /************/ class WinEnd extends WindowAdapter { public void windowClosing(WindowEvent e) { System.exit(0); } } }