import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class SimpleButtonEvent extends Applet
implements ActionListener {
private Button b, b1, b2,b3,b4,b5,b6,b7,b8,b9,b10;
//Label l = new Label("felix, from usa");
//private TeatArea t1;
public void init() {
b = new Button("Programmer Name");
b.addActionListener(this);
add(b);
b1 = new Button("red");
b1.addActionListener(this);
add(b1);
b2 = new Button("green");
b2.addActionListener(this);
add(b2);
b3 = new Button("black");
b3.addActionListener(this);
add(b3);
b4 = new Button("yellow");
b4.addActionListener(this);
add(b4);
b5 = new Button("cyan");
b5.addActionListener(this);
add(b5);
b6 = new Button("white");
b6.addActionListener(this);
add(b6);
TextArea t1 = new TextArea("10,10");
// t1.addActionListener(this);
t1.setText("Sachin was born on 24th april 1973. \nHe father was a marathi poet and his mother worke for lic.
\nSachin first one day carrer on 5th june 1992.\nSachin hits first century in newzeland on 1992.\nAnyother Sachin called is
MASTER BJASTER.\nSachin is a god cricket player.\nHe is the next brateman of cricket.\nSachin is the right hand batsman.\nSachin
is the world top batsman.\nSachin hits a many centures in one day cricket. ");
// t1.setText("felix");
add(t1);
TextArea t2 = new TextArea("10,20");
t2.setText("type this place");
add(t2);
}
public void actionPerformed(ActionEvent e) {
// If the target of the event was our Button
// In this example, the check is not
// truly necessary as we only listen to
// a single button
if ( e.getSource() == b ) {
getGraphics().drawString("Programmed by : Felix",20,90);
getGraphics().drawString("HELLO ",20,230);
//DialogFrame df = new DialogFrame();
//df.setSize(400,400);
//df.show();
}
if ( e.getSource() == b1) {
b1.setBackground(Color.red);
setBackground(Color.red);
}
if ( e.getSource() == b2) {
b2.setBackground(Color.green);
setBackground(Color.green);
}
if ( e.getSource() == b3) {
b3.setBackground(Color.black);
b3.setForeground(Color.white);
setBackground(Color.black);
}
if ( e.getSource() == b4) {
b4.setBackground(Color.yellow);
setBackground(Color.yellow);
}
if ( e.getSource() == b5) {
b5.setBackground(Color.cyan);
setBackground(Color.cyan);
}
if ( e.getSource() == b6) {
b6.setBackground(Color.white);
setBackground(Color.white);
}
//rkthread r = new rkthread();
}
}

|