// <applet code=Button2b
// width=350 height=100></applet>
public class Button2b extends JApplet {
JButton
b1 = new JButton("Button 1"),
b2 = new JButton("Button 2");
JLabel txt = new JLabel("This is a Lebel");
ActionListener AL = new ActionListener() {
public void actionPerformed(ActionEvent e){
JButton b = (JButton)e.getSource();
String name = b.getText();
txt.setText(name);
b.setBackground(Color.red);
b.setEnabled(false);
}
};
public void init() {
b1.addActionListener(AL);
b2.addActionListener(AL);
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
cp.add(b1);
cp.add(b2);
cp.add(txt);
}
public static void main(String[] args) {
Console.run(new Button2b(), 200, 75);
}
}