import java.awt.*;
import java.awt.event.*;
public class GiGi implements ActionListener{
      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 GiGi();
   }
   public GiGi() {  // 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.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.setVisible(true);  //f.show();
   }
   public void actionPerformed(ActionEvent evt){
	      if(evt.getSource() == n){
	          n.setBackground(Color.red);
             n.setLabel(" 777 ");
	      } /* evt...  == n */
	      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 ...
	   } /* actionPerformed */

}
