- java.lang.Object
-
- java.awt.Component
-
- java.awt.Button
-
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible
public class Button extends Component implements Accessible
This class creates a labeled button. The application can cause some action to happen when the button is pushed. This image depicts three views of a "Quit" button as it appears under the Solaris operating system:
The first view shows the button as it appears normally. The second view shows the button when it has input focus. Its outline is darkened to let the user know that it is an active object. The third view shows the button when the user clicks the mouse over the button, and thus requests that an action be performed.
The gesture of clicking on a button with the mouse is associated with one instance of
ActionEvent, which is sent out when the mouse is both pressed and released over the button. If an application is interested in knowing when the button has been pressed but not released, as a separate gesture, it can specializeprocessMouseEvent, or it can register itself as a listener for mouse events by callingaddMouseListener. Both of these methods are defined byComponent, the abstract superclass of all components.When a button is pressed and released, AWT sends an instance of
ActionEventto the button, by callingprocessEventon the button. The button'sprocessEventmethod receives all events for the button; it passes an action event along by calling its ownprocessActionEventmethod. The latter method passes the action event on to any action listeners that have registered an interest in action events generated by this button.If an application wants to perform some action based on a button being pressed and released, it should implement
ActionListenerand register the new listener to receive events from this button, by calling the button'saddActionListenermethod. The application can make use of the button's action command as a messaging protocol.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classButton.AccessibleAWTButtonThis class implements accessibility support for theButtonclass.-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT,
-
-