With JDK 1.1, you can define an action command String for a Button that is independent of the text displayed in the Button. At the least, this enables you to separate the testing for which Button has been pressed from the spelling of the label. At best, it helps keep the code smaller if you add multiple-language support. With 1.1’s event model, it is unlikely that you will create a Button without nominating a listener for the action event. But the unchanged set of Button constructors does not encourage the use of either of these features. The following simple extension to the Button class should help.
import java.awt.*;import java.awt.event.*;public class Button11 extends Button { public Button11(String caption, String command, ActionListener waiting) { super(caption); if (command != null) setActionCommand (command); if (waiting != null) addActionListener(waiting); }}