java.awt
public class Button extends Component implements Serializable, Accessible
Nested Class Summary | |
---|---|
protected class | Button.AccessibleAWTButton |
Constructor Summary | |
---|---|
Button()
Initializes a new instance of Button with no label.
| |
Button(String label)
Initializes a new instance of Button with the specified
label. |
Method Summary | |
---|---|
void | addActionListener(ActionListener listener)
Adds a new entry to the list of listeners that will receive
action events from this button.
|
void | addNotify()
Notifies this button that it should create its native peer object. |
AccessibleContext | getAccessibleContext()
Gets the AccessibleContext associated with this Button .
|
String | getActionCommand()
Returns the action command name for this button.
|
ActionListener[] | getActionListeners()
Returns all added ActionListener objects.
|
String | getLabel()
Returns the label for this button.
|
<T extends EventListener> T[] | getListeners(Class<T> listenerType)
Returns all registered EventListers of the given listenerType.
listenerType must be a subclass of EventListener, or a
ClassClassException is thrown.
|
protected String | paramString()
Returns a debugging string for this button.
|
protected void | processActionEvent(ActionEvent event)
This method dispatches an action event for this button to any
registered listeners.
|
protected void | processEvent(AWTEvent event)
Processes an event for this button. |
void | removeActionListener(ActionListener listener)
Removes the specified listener from the list of listeners that will
receive action events from this button.
|
void | setActionCommand(String actionCommand)
Sets the action command name for this button to the specified value.
|
void | setLabel(String label)
Sets the label for this button to the specified value.
|
Button
with no label.
Throws: HeadlessException If GraphicsEnvironment.isHeadless() returns true
Button
with the specified
label. The action command name is also initialized to this value.
Parameters: label The label to display on the button.
Throws: HeadlessException If GraphicsEnvironment.isHeadless() returns true
Parameters: listener The listener to add.
Button
.
The context is created, if necessary.
Returns: the associated context
Returns: The action command name for this button.
ActionListener
objects.
Returns: an array of listeners
Since: 1.4
Returns: The label for this button.
Parameters: listenerType the listener type to return
Returns: an array of listeners
Throws: ClassCastException If listenerType doesn't specify a class or interface that implements @see java.util.EventListener.
Since: 1.3
Returns: A debugging string for this button.
Parameters: event The event to process.
ActionEvent
, then the
processActionEvent()
method is called to dispatch it
to any registered listeners. Otherwise, the superclass method
will be invoked. Note that this method will not be called at all
unless ActionEvent
's are enabled. This will be done
implicitly if any listeners are added.
Parameters: event The event to process.
Parameters: listener The listener to remove.
Parameters: actionCommand The new action command name.
Parameters: label The new label for this button.