import java.awt.*;
import java.awt.event.*;
public class GiGi5 implements ActionListener, WindowListener{
      Frame f = new Frame("Window 2001");
      Button b1,b2,b3;
      Panel p;       Button n, bq, big;
      int xSize=300, ySize=200;
      Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
      TextArea tx=
    new TextArea("Hey 我愛 GiGi", 5,20,TextArea.SCROLLBARS_HORIZONTAL_ONLY);
   public static void main( String s[]) {
      new GiGi5();
   }
   public GiGi5() {  // Constructor
      f.setSize(xSize,ySize); f.setLocation(100,100);
      tx.append("\n=== ==== ====       TextArea tx=");
      tx.append(" new TextArea(\"Hey 我愛 GiGi\", 5,20,");
      tx.append(" TextArea.SCROLLBARS_HORIZONTAL_ONLY);\n");
      tx.append("If  如果 GiGi 不漂亮, 你還會覺得她的歌好聽嗎?\n");
      b1=new Button("111"); b2=new Button("222");
      p = new Panel(); n= new Button("HahaHehehe"); p.add(n);
      bq=new Button("Quit"); p.add(bq);
      bq.setBackground(new Color(38,38,38)); bq.setForeground(Color.red);
      big=new Button("Bigger"); p.add(big);
      big.setFont(new Font("",Font.BOLD,24) );
      big.setForeground(new Color(255,0,0));
      n.setBackground(Color.green);
      n.addActionListener(this); //有事交給此程式中的actionPerformed()
      b1.addActionListener(this);
      bq.addActionListener(this);
      big.addActionListener(this);
      f.add(tx,"Center");
      f.add(b1,"West"); ; f.add(b2,"East");
      f.add(p,"South"); f.show();
      f.addWindowListener(this);
   }
   public void actionPerformed(ActionEvent evt){
      if(evt.getSource() == n){
          n.setBackground(Color.red); n.setLabel(" 777 ");}
      if(evt.getSource() == b1) n.setLabel("Eleven");
      if(evt.getSource() == bq) System.exit(0);
      if(evt.getSource() == big){
         xSize = (int) (xSize*1.2); if(xSize>dim.width) xSize= dim.width;
         ySize = (int) (ySize*1.2); if(ySize>dim.height) ySize= dim.height;
         tx.append("\n"+xSize+ "," + ySize);
         f.setSize(xSize,ySize);
      }
      f.validate();  // so that Layout Manager ...
   }
////// for WindowListener
 public void windowClosed(WindowEvent e) {;}
 public void windowDeiconified(WindowEvent e) {;}
 public void windowIconified(java.awt.event.WindowEvent e) {}
 public void windowDeactivated(java.awt.event.WindowEvent e) {}
 public void windowActivated(java.awt.event.WindowEvent e) {}
 public void windowOpened(java.awt.event.WindowEvent e) {}
 public void windowClosing(java.awt.event.WindowEvent e) {System.exit(38);}
}
