One of the most commonly used Swing controls is the push button. A push button is an instance of JButton. JButton inherits the abstract class AbstractButton, which defines the functionality common to all buttons. Swing push buttons can contain text, an image, or both, but this book uses only text-based buttons.
JButton supplies several constructors. The one used here is
Here, msg specifies the string that will be displayed inside the button.
When a push button is pressed, it generates an ActionEvent. ActionEvent is defined by the AWT and also used by Swing. JButton provides the following methods, which are used to add or remove an action listener:
void addActionListener(ActionListener al)
void removeActionListener(ActionListener ...