import java.awt.*; import java.awt.event.*; public class GiGi3 implements ActionListener{ Frame f = new Frame("Window 2003"); Button b1,b2,b3; Panel p; Button n; public static void main( String s[]) { new GiGi3(); /* easy to change to Applet */ } public GiGi3( ) { // Constructor f.setSize(300,200); b1=new Button("111"); b2=new Button("222"); p = new Panel(); f.add(p,"South"); f.add(b1,"West"); f.add(b2,"East"); Button bq = new Button("Quit"); n= new Button("HahaHehehe"); p.add(n); p.add(bq); n.setBackground(Color.green); n.addActionListener(this); // register with ActionListener b1.addActionListener(this); bq.addActionListener(this); // no use 'cause bq Local here f.setVisible(true); } public void actionPerformed (ActionEvent evt){ if(evt.getSource( ) == n) { n.setBackground(Color.red); n.setLabel(" 777 ");} if(evt.getSource( ) == b1) n.setLabel("Eleven"); // bq can NOT be seen here 'cause it is not Global f.validate( ); // so that Layout Manager ... } }