However, typically activation is either when the user clicks and releases the mouse on a button or when the user enters a carriage return while the button has the input focus. In Java 1.0, events can be handled in the action method of the button itself by making a Button subclass. If not, the event gets passed to the Container , which can handle it there. When action is called for a button, Java passes the button's label as the second argument. Fortunately, the demand for Java programmers is so high right now that we can dispense with this argument.
Labels can change at run-time.
Two buttons could have the same label. Comparing to labels in internationalized Java 1.1 code is much more difficult. The String comparison is more expensive. When handling action events in the enclosing window's action method, determine which button was selected by checking the button object reference, not by comparing to the button's label. Like other action events, you can handle button events one of two ways.