Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class Button

java.lang.Object
|
+--java.awt.Component
   |
   +--java.awt.Button

All Implemented Interfaces:

Serializable, ImageObserver, MenuContainer, Serializable


public class Button

extends Component

implements Serializable

This class provides a button widget for the AWT.

Authors:

Constructor Summary

Button()

Initializes a new instance of Button with no label.
Button(java.lang.String label)

Initializes a new instance of Button with the specified label.

Method Summary

synchronized voidaddActionListener(java.awt.event.ActionListener listener)

Adds a new entry to the list of listeners that will receive action events from this button.
voidaddNotify()

Notifies this button that it should create its native peer object.
java.lang.StringgetActionCommand()

Returns the action command name for this button.
synchronized java.awt.event.ActionListener[]getActionListeners()

java.lang.StringgetLabel()

Returns the label for this button.
java.util.EventListener[]getListeners(java.lang.Class listenerType)

Returns all registered EventListers of the given listenerType.
java.lang.StringparamString()

Returns a debugging string for this button.
voidprocessActionEvent(java.awt.event.ActionEvent event)

This method dispatches an action event for this button to any registered listeners.
voidprocessEvent(java.awt.AWTEvent event)

Processes an event for this button.
synchronized voidremoveActionListener(java.awt.event.ActionListener listener)

Removes the specified listener from the list of listeners that will receive action events from this button.
voidsetActionCommand(java.lang.String actionCommand)

Sets the action command name for this button to the specified value.
synchronized voidsetLabel(java.lang.String label)

Sets the label for this button to the specified value.

Constructor Details

Button

public Button()

Initializes a new instance of Button with no label.

Throws:


Button

public Button(java.lang.String label)

Initializes a new instance of Button with the specified label. The action command name is also initialized to this value.

Parameters:

Throws:


Method Details

addActionListener

public synchronized void addActionListener(java.awt.event.ActionListener listener)

Adds a new entry to the list of listeners that will receive action events from this button.

Parameters:


addNotify

public void addNotify()

Notifies this button that it should create its native peer object.


getActionCommand

public String getActionCommand()

Returns the action command name for this button.

Returns:


getActionListeners

public synchronized ActionListener[] getActionListeners()


getLabel

public String getLabel()

Returns the label for this button.

Returns:


getListeners

public EventListener[] getListeners(java.lang.Class listenerType)

Returns all registered EventListers of the given listenerType. listenerType must be a subclass of EventListener, or a ClassClassException is thrown.

Since:Parameters:

Throws:


paramString

protected String paramString()

Returns a debugging string for this button.

Returns:


processActionEvent

protected void processActionEvent(java.awt.event.ActionEvent event)

This method dispatches an action event for this button to any registered listeners.

Parameters:


processEvent

protected void processEvent(java.awt.AWTEvent event)

Processes an event for this button. If the specified event is an instance of 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:


removeActionListener

public synchronized void removeActionListener(java.awt.event.ActionListener listener)

Removes the specified listener from the list of listeners that will receive action events from this button.

Parameters:


setActionCommand

public void setActionCommand(java.lang.String actionCommand)

Sets the action command name for this button to the specified value.

Parameters:


setLabel

public synchronized void setLabel(java.lang.String label)

Sets the label for this button to the specified value.

Parameters: