ウインドウの導入
addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } });
import java.awt.*; import java.awt.event.*; public class gFrame extends Frame{ //ウインドウを作成し、表示します public static void main(String[] args) { newFrame nf=new newFrame(); nf.show(); } } class newFrame extends Frame{ private TextField textField1 = new TextField(); newFrame(){ super("Hello");//ウインドウのタイトルを指定 setSize(200,150);//ウインドウのサイズを指定 addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0);//終了イベント } }); textField1.setText("hello");//GUI部品の生成 textField1.setBounds(new Rectangle(30, 50, 130, 20)); setLayout(null); add(textField1, null);//部品の追加 } public void paint(Graphics g){ g.drawString("Hello",30,100);//グラフィック表示 } }