/*ch0701.java*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ch0701 extends JFrame implements ActionListener
{ JTextField tf=new JTextField(10);
  JButton bt=new JButton("ok");
  static int i=0;
  public ch0701()
  { super("图形用户界面框架");                
    Container c=getContentPane();            //获得窗口的内容显示层
    c.setLayout(new FlowLayout());           //设置显示层的布局方式
    c.add(tf);c.add(bt);setSize(200,100);    //添加组件
    setVisible(true);                        //显示窗口界面
    bt.addActionListener(this);              //给组件添加监听
    addWindowListener(new WindowAdapter()
    { public void windowClosing(WindowEvent e)
      { System.exit(0);
      }
    });
  }

  public void actionPerformed(ActionEvent e) //事件处理程序
  { i=i+1;
    if(i%2==0) tf.setText("aaaaa");
    else tf.setText("bbbbb");
  }

  public static void main(String args[])
  { new ch0701();
  }
}
