java::awt::Button Class Reference

Inheritance diagram for java::awt::Button:

Inheritance graph
java::awt::Componentjava::lang::Objectjava::lang::Interfacejava::lang::Syncjava::awt::event::ComponentSourcejava::awt::event::FocusSourcejava::awt::event::HierarchySourcejava::awt::event::KeySourcejava::awt::event::MouseSourcejava::awt::event::PaintSourcejava::util::PropertyChangeSourcejava::awt::event::ActionSourcejava::lang::Lockjava::lang::ScopeAdapterjava::awt::image::ImageObserverjava::util::EventSource
[legend]
Collaboration diagram for java::awt::Button:

Collaboration graph
java::awt::Componentjava::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::lang::Syncjava::awt::event::ComponentSourcejava::awt::event::FocusSourcejava::awt::event::HierarchySourcejava::awt::event::KeySourcejava::awt::event::MouseSourcejava::awt::event::PaintSourcejava::util::PropertyChangeSourcejava::awt::event::ActionSourcejava::lang::Lockjava::lang::ScopeAdapterjava::lang::Comparablejava::awt::image::ImageObserverjava::util::EventSourcejava::util::Collectionjava::util::LinkedListjava::util::AbstractSequentialListjava::util::AbstractListjava::util::AbstractCollectionjava::util::List
[legend]

List of all members.


Detailed Description

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 "<code>Quit</code>" button as it appears under the Solaris operating system:

Button-1.gif

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 specialize processMouseEvent, or it can register itself as a listener for mouse events by calling addMouseListener. Both of these methods are defined by Component, the abstract superclass of all components.

When a button is pressed and released, AWT sends an instance of ActionEvent to the button, by calling processEvent on the button. The button's processEvent method receives all events for the button; it passes an action event along by calling its own processActionEvent method. 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 ActionListener and register the new listener to receive events from this button, by calling the button's addActionListener method. The application can make use of the button's action command as a messaging protocol.

Version:
1.73 01/23/03
Author:
Sami Shaio
See also:
java.awt.event.ActionEvent

java.awt.event.ActionListener

java.awt.Component::processMouseEvent

java.awt.Component::addMouseListener

Since:
JDK1.0

Public Member Functions

 Button (const String &label=nilString)
 Constructs a Button with the specified label.
virtual String getLabel () const
 Gets the label of this button.
virtual void setLabel (const String &label)
 Gets the label of this button.
virtual String getActionCommand () const
 Returns the command name of the action event fired by this button.
virtual void setActionCommand (const String &command)
 Sets the command name for the action event fired by this button.
virtual String toString () const
 Returns a string representation of this component and its values.

Protected Attributes

 REGISTER_MEMBERS

Constructor & Destructor Documentation

java::awt::Button::Button ( const String label = nilString  ) 

Constructs a Button with the specified label.

Parameters:
label A string label for the button.
Exceptions:
HeadlessException if GraphicsEnvironment.isHeadless() returns true
See also:
java.awt.GraphicsEnvironment::isHeadless


Member Function Documentation

virtual String java::awt::Button::getLabel (  )  const [virtual]

Gets the label of this button.

Returns:
the button's label, or null if the button has no label.
See also:
java.awt.Button::setLabel

virtual void java::awt::Button::setLabel ( const String label  )  [virtual]

Gets the label of this button.

Returns:
the button's label, or null if the button has no label.
See also:
java.awt.Button::setLabel

virtual String java::awt::Button::getActionCommand (  )  const [virtual]

Returns the command name of the action event fired by this button.

If the command name is null (default) then this method returns the label of the button.

Implements java::awt::event::ActionSource.

virtual void java::awt::Button::setActionCommand ( const String command  )  [virtual]

Sets the command name for the action event fired by this button.

By default this action command is set to match the label of the button.

Parameters:
command A string used to set the button's action command. If the string is null then the action command is set to match the label of the button.
See also:
java.awt.event.ActionEvent
Since:
JDK1.1

virtual String java::awt::Button::toString (  )  const [virtual]

Returns a string representation of this component and its values.

Returns:
a string representation of this component
Since:
JDK1.0

Reimplemented from java::awt::Component.


Member Data Documentation

java::awt::Button::REGISTER_MEMBERS [protected]

Reimplemented from java::awt::Component.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:55:52 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3