/* * 1.0 version. */ import java.awt.*; import java.applet.Applet; public class ButtonDemo extends Applet { Button b1, b2, b3; public void init() { b1 = new Button(); b1.setLabel("Disable middle button"); b2 = new Button("Middle button"); b3 = new Button("Enable middle button"); b3.disable(); //Add Components to the Applet, using the default FlowLayout. add(b1); add(b2); add(b3); //Necessary when adding buttons to an already visible container: validate(); } public boolean action(Event e, Object arg) { Object target = e.target; if (target == b1) { //They clicked "Disable middle button" b2.disable(); b1.disable(); b3.enable(); return true; } if (target == b3) { //They clicked "Enable middle button" b2.enable(); b1.enable(); b3.disable(); return true; } return false; } }