|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.4.2
java.awt
|
Nested Class Summary | |
protected class |
Button.AccessibleAWTButton
This class implements accessibility support for the Button class. |
Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
Button()
Constructs a Button with no label. |
|
Button(String label)
Constructs a Button with the specified label. |
Method Summary | |
void |
addActionListener(ActionListener l)
Adds the specified action listener to receive action events from this button. |
void |
addNotify()
Creates the peer of the button. |
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with
this Button . |
String |
getActionCommand()
Returns the command name of the action event fired by this button. |
ActionListener[] |
getActionListeners()
Returns an array of all the action listeners registered on this button. |
String |
getLabel()
Gets the label of this button. |
EventListener[] |
getListeners(Class listenerType)
Returns an array of all the objects currently registered as FooListener s
upon this Button . |
protected String |
paramString()
Returns a string representing the state of this Button . |
protected void |
processActionEvent(ActionEvent e)
Processes action events occurring on this button by dispatching them to any registered ActionListener objects. |
protected void |
processEvent(AWTEvent e)
Processes events on this button. |
void |
removeActionListener(ActionListener l)
Removes the specified action listener so that it no longer receives action events from this button. |
void |
setActionCommand(String command)
Sets the command name for the action event fired by this button. |
void |
setLabel(String label)
Sets the button's label to be the specified string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Button() throws HeadlessException
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
public Button(String label) throws HeadlessException
label
- A string label for the button.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
Method Detail |
public void addNotify()
public String getLabel()
null
if the button has no label.setLabel(java.lang.String)
public void setLabel(String label)
label
- the new label, or null
if the button has no label.getLabel()
public void setActionCommand(String command)
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.ActionEvent
public String getActionCommand()
null
(default) then this method
returns the label of the button.
public void addActionListener(ActionListener l)
l
- the action listenerremoveActionListener(java.awt.event.ActionListener)
,
getActionListeners()
,
ActionListener
public void removeActionListener(ActionListener l)
l
- the action listeneraddActionListener(java.awt.event.ActionListener)
,
getActionListeners()
,
ActionListener
public ActionListener[] getActionListeners()
ActionListener
s
or an empty array if no action
listeners are currently registeredaddActionListener(java.awt.event.ActionListener)
,
removeActionListener(java.awt.event.ActionListener)
,
ActionListener
public EventListener[] getListeners(Class listenerType)
FooListener
s
upon this Button
.
FooListener
s are registered using the
addFooListener
method.
You can specify the listenerType
argument
with a class literal, such as
FooListener.class
.
For example, you can query a
Button
b
for its action listeners with the following code:
ActionListener[] als = (ActionListener[])(b.getListeners(ActionListener.class));If no such listeners exist, this method returns an empty array.
getListeners
in class Component
listenerType
- the type of listeners requested; this parameter
should specify an interface that descends from
java.util.EventListener
FooListener
s on this button,
or an empty array if no such
listeners have been added
ClassCastException
- if listenerType
doesn't specify a class or interface that implements
java.util.EventListener
getActionListeners()
protected void processEvent(AWTEvent e)
ActionEvent
, this method invokes
the processActionEvent
method. Otherwise,
it invokes processEvent
on the superclass.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
processEvent
in class Component
e
- the eventActionEvent
,
processActionEvent(java.awt.event.ActionEvent)
protected void processActionEvent(ActionEvent e)
ActionListener
objects.
This method is not called unless action events are enabled for this button. Action events are enabled when one of the following occurs:
ActionListener
object is registered
via addActionListener
.
enableEvents
.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
e
- the action eventActionListener
,
addActionListener(java.awt.event.ActionListener)
,
Component.enableEvents(long)
protected String paramString()
Button
.
This method is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null
.
paramString
in class Component
public AccessibleContext getAccessibleContext()
AccessibleContext
associated with
this Button
. For buttons, the
AccessibleContext
takes the form of an
AccessibleAWTButton
.
A new AccessibleAWTButton
instance is
created if necessary.
getAccessibleContext
in interface Accessible
getAccessibleContext
in class Component
AccessibleAWTButton
that serves as the
AccessibleContext
of this Button