フレーム作成
●サンプル
import java.awt.*; //Frameクラスなどをインポート
import java.awt.event.*; //WindowAdapterなどをインポート
public class Sample {
public static void main(String args[]) {
Frame frame = new Frame(); //ウィンドウフレームを作成
frame.setSize(200, 100); //ウィンドウのサイズ指定
frame.setVisible(true); //ウィンドウを表示
frame.addWindowListener(new Ada()); //windowClosingメソッドの呼び出し
}
}
class Ada extends WindowAdapter {
public void windowClosing(WindowEvent e) { //×を押した時の処理
System.exit(0); //ウィンドウを閉じる
}
}
●実行結果
