Вы находитесь на странице: 1из 10

ActionListener (Java Platform SE 7 )

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionListe...

Overview Package

Class

Use Tree

Deprecated Index Help

Frames No Frames
Summary: Nested | Field | Constr | Method Detail: Field | Constr | Method

java.awt.event

EventListener

Action

AbstractAction, AWTEventMulticaster, BasicDesktopPaneUI.CloseAction, BasicDesktopPaneUI.MaximizeAction, BasicDesktopPaneUI.MinimizeAction, BasicDesktopPaneUI.NavigateAction, BasicDesktopPaneUI.OpenAction, BasicFileChooserUI.ApproveSelectionAction, BasicFileChooserUI.CancelSelectionAction, BasicFileChooserUI.ChangeToParentDirectoryAction, BasicFileChooserUI.GoHomeAction, BasicFileChooserUI.NewFolderAction, BasicFileChooserUI.UpdateAction, BasicInternalFrameTitlePane.CloseAction, BasicInternalFrameTitlePane.IconifyAction, BasicInternalFrameTitlePane.MaximizeAction, BasicInternalFrameTitlePane.MoveAction, BasicInternalFrameTitlePane.RestoreAction, BasicInternalFrameTitlePane.SizeAction, BasicOptionPaneUI.ButtonActionListener, BasicScrollBarUI.ScrollListener, BasicSliderUI.ActionScroller, BasicSliderUI.ScrollListener, BasicSplitPaneUI.KeyboardDownRightHandler, BasicSplitPaneUI.KeyboardEndHandler, BasicSplitPaneUI.KeyboardHomeHandler, BasicSplitPaneUI.KeyboardResizeToggleHandler, BasicSplitPaneUI.KeyboardUpLeftHandler, BasicTreeUI.ComponentHandler, BasicTreeUI.TreeCancelEditingAction, BasicTreeUI.TreeHomeAction, BasicTreeUI.TreeIncrementAction, BasicTreeUI.TreePageAction, BasicTreeUI.TreeToggleAction, BasicTreeUI.TreeTraverseAction, DefaultCellEditor.EditorDelegate, DefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction, DefaultTreeCellEditor, DropTarget.DropTargetAutoScroller, FormView, HTMLEditorKit.HTMLTextAction, HTMLEditorKit.InsertHTMLTextAction, JComboBox, List.AccessibleAWTList, MetalFileChooserUI.DirectoryComboBoxAction, StyledEditorKit.AlignmentAction, StyledEditorKit.BoldAction, StyledEditorKit.FontFamilyAction, StyledEditorKit.FontSizeAction, StyledEditorKit.ForegroundAction, StyledEditorKit.ItalicAction, StyledEditorKit.StyledTextAction, StyledEditorKit.UnderlineAction, TextAction, ToolTipManager.insideTimerAction, ToolTipManager.outsideTimerAction, ToolTipManager.stillInsideTimerAction

public interface extends EventListener


The listener interface for receiving action events. The class that is interested in processing an action event implements this interface, and the object created with that class is registered with a component, using the component's addActionListener method. When the action event occurs, that object's actionPerformed method is invoked.

1.1

ActionEvent, Tutorial: Java 1.1 Event Model

1 de 2

08/11/2013 16:17

ActionListener (Java Platform SE 7 )

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionListe...

void

( Invoked when an action occurs.

e)

void actionPerformed(ActionEvent e)
Invoked when an action occurs.

Overview Package

Class

Use Tree

Deprecated Index Help

Frames No Frames
Summary: Nested | Field | Constr | Method Detail: Field | Constr | Method

Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright 1993, 2013, Oracle and/or its affiliates. All rights reserved.

2 de 2

08/11/2013 16:17

ActionEvent (Java Platform SE 7 )

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionEvent...

Overview Package Prev Class

Class

Use Tree Frames

Deprecated Index Help

No Frames
Detail: Field | Constr | Method

Summary: Nested | Field | Constr | Method

java.awt.event

java.lang.Object java.util.EventObject java.awt.AWTEvent java.awt.event.ActionEvent

Serializable

public class extends AWTEvent


A semantic event which indicates that a component-defined action occurred. This high-level event is generated by a component (such as a Button) when the component-specific action occurs (such as being pressed). The event is passed to every ActionListener object that registered to receive such events using the component's addActionListener method. To invoke an ActionEvent on a Button using the keyboard, use the Space bar. The object that implements the ActionListener interface gets this ActionEvent when the event occurs. The listener is therefore spared the details of processing individual mouse movements and mouse clicks, and can instead process a "meaningful" (semantic) event like "button pressed". An unspecified behavior will be caused if the id parameter of any particular ActionEvent instance is not in the range from ACTION_FIRST to ACTION_LAST.

1.1

ActionListener, Tutorial: How to Write an Action Listener, Serialized Form

static int The first number in the range of ids used for action events. static int The last number in the range of ids used for action events. static int This event id indicates that a meaningful action occured. static int The alt modifier. static int The control modifier. static int The meta modifier.

1 de 7

08/11/2013 16:17

ActionEvent (Java Platform SE 7 )

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionEvent...

static int The shift modifier.

ACTION_EVENT_MASK, ADJUSTMENT_EVENT_MASK, COMPONENT_EVENT_MASK, consumed, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, HIERARCHY_BOUNDS_EVENT_MASK, HIERARCHY_EVENT_MASK, id, INPUT_METHOD_EVENT_MASK, INVOCATION_EVENT_MASK, ITEM_EVENT_MASK, KEY_EVENT_MASK, MOUSE_EVENT_MASK, MOUSE_MOTION_EVENT_MASK, MOUSE_WHEEL_EVENT_MASK, PAINT_EVENT_MASK, RESERVED_ID_MAX, TEXT_EVENT_MASK, WINDOW_EVENT_MASK, WINDOW_FOCUS_EVENT_MASK, WINDOW_STATE_EVENT_MASK

source

( source, int id, Constructs an ActionEvent object. ( source, int id, Constructs an ActionEvent object with modifier keys.

command) command, int modifiers)

( source, int id, command, long when, int modifiers) Constructs an ActionEvent object with the specified modifier keys and timestamp.

() Returns the command string associated with this action. int long () Returns the modifier keys held down during this action event. () Returns the timestamp of when this event occurred. () Returns a parameter string identifying this action event.

consume, getID, isConsumed, setSource, toString

getSource

2 de 7

08/11/2013 16:17

ActionEvent (Java Platform SE 7 )

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionEvent...

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

public static final int SHIFT_MASK


The shift modifier. An indicator that the shift key was held down during the event.

Constant Field Values

public static final int CTRL_MASK


The control modifier. An indicator that the control key was held down during the event.

Constant Field Values

public static final int META_MASK


The meta modifier. An indicator that the meta key was held down during the event.

Constant Field Values

public static final int ALT_MASK


The alt modifier. An indicator that the alt key was held down during the event.

Constant Field Values

public static final int ACTION_FIRST


The first number in the range of ids used for action events.

3 de 7

08/11/2013 16:17

ActionEvent (Java Platform SE 7 )

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionEvent...

Constant Field Values

public static final int ACTION_LAST


The last number in the range of ids used for action events.

Constant Field Values

public static final int ACTION_PERFORMED


This event id indicates that a meaningful action occured.

Constant Field Values

public ActionEvent(Object source, int id, String command)


Constructs an ActionEvent object. This method throws an IllegalArgumentException if source is null. A null command string is legal, but not recommended.

source - The object that originated the event id - An integer that identifies the event. For information on allowable values, see the class description for ActionEvent command - A string that may specify a command (possibly one of several) associated with the event

IllegalArgumentException - if source is null

EventObject.getSource(), AWTEvent.getID(), getActionCommand()

public ActionEvent(Object source, int id, String command, int modifiers)

4 de 7

08/11/2013 16:17

ActionEvent (Java Platform SE 7 )

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionEvent...

Constructs an ActionEvent object with modifier keys. This method throws an IllegalArgumentException if source is null. A null command string is legal, but not recommended.

source - The object that originated the event id - An integer that identifies the event. For information on allowable values, see the class description for ActionEvent command - A string that may specify a command (possibly one of several) associated with the event modifiers - The modifier keys down during event (shift, ctrl, alt, meta). Passing negative parameter is not recommended. Zero value means that no modifiers were passed

IllegalArgumentException - if source is null

EventObject.getSource(), AWTEvent.getID(), getActionCommand(), getModifiers()

public ActionEvent(Object source, int id, String command, long when, int modifiers)
Constructs an ActionEvent object with the specified modifier keys and timestamp. This method throws an IllegalArgumentException if source is null. A null command string is legal, but not recommended.

source - The object that originated the event id - An integer that identifies the event. For information on allowable values, see the class description for ActionEvent command - A string that may specify a command (possibly one of several) associated with the event modifiers - The modifier keys down during event (shift, ctrl, alt, meta). Passing negative parameter is not recommended. Zero value means that no modifiers were passed when - A long that gives the time the event occurred. Passing negative or zero value is not recommended

IllegalArgumentException - if source is null

1.4

EventObject.getSource(), AWTEvent.getID(), getActionCommand(), getModifiers(), getWhen()

5 de 7

08/11/2013 16:17

ActionEvent (Java Platform SE 7 )

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionEvent...

public String getActionCommand()


Returns the command string associated with this action. This string allows a "modal" component to specify one of several commands, depending on its state. For example, a single button might toggle between "show details" and "hide details". The source object and the event would be the same in each case, but the command string would identify the intended action. Note that if a null command string was passed to the constructor for this ActionEvent, this this method returns null.

the string identifying the command for this event

public long getWhen()


Returns the timestamp of when this event occurred. Because an ActionEvent is a high-level, semantic event, the timestamp is typically the same as an underlying InputEvent.

this event's timestamp

1.4

public int getModifiers()


Returns the modifier keys held down during this action event.

the bitwise-or of the modifier constants

public String paramString()


Returns a parameter string identifying this action event. This method is useful for event-logging and for debugging.

paramString in class AWTEvent

a string identifying the event and its associated command

6 de 7

08/11/2013 16:17

ActionEvent (Java Platform SE 7 )

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionEvent...

Overview Package Prev Class

Class

Use Tree Frames

Deprecated Index Help

No Frames
Detail: Field | Constr | Method

Summary: Nested | Field | Constr | Method

Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright 1993, 2013, Oracle and/or its affiliates. All rights reserved.

7 de 7

08/11/2013 16:17

ActionListener (Java Platform SE 7 )

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionListe...

void

( Invoked when an action occurs.

e)

void actionPerformed(ActionEvent e)
Invoked when an action occurs.

Overview Package

Class

Use Tree

Deprecated Index Help

Frames No Frames
Summary: Nested | Field | Constr | Method Detail: Field | Constr | Method

Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright 1993, 2013, Oracle and/or its affiliates. All rights reserved.

2 de 2

08/11/2013 16:17

Вам также может понравиться