The java.awt.event package defines classes and interfaces used for event handling in the AWT and Swing. The members of this package fall into three categories:
The classes with names ending in "Event" represent specific types of events, generated by the AWT or by one of the AWT or Swing components.
The interfaces in this package are all event listeners; their names end with "Listener". These interfaces define the methods that must be implemented by any object that wants to be notified when a particular event occurs. Note that there is a Listener interface for each Event class.
Each of the classes with a name ending in "Adapter" provides a no-op implementation for an event listener interface that defines more than one method. When you are interested in only a single method of an event listener interface, it is easier to subclass an Adapter class than to implement all of the methods of the corresponding Listener interface.
Figure 14-1 shows the class hierarchy of this package.
The Swing user-interface components use some of these event classes and interfaces and also define others in the javax.swing.event package. The java.beans package also defines a few commonly used event classes and listener interfaces. Note that this package is part of the Java 1.1 event model. In Java 1.0, events were represented by the java.awt.Event class. See Chapter 2, "Swing and AWTArchitecture", for an introduction to events and event handling.
ActionEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
An object of this class represents a high-level action event generated by an AWT component. Instead of representing a direct user event, such as a mouse or keyboard event, ActionEvent represents some sort of action performed by the user on an AWT component.
The getID() method returns the type of action that has occurred. For AWT-generated action events, this type is always ActionEvent.ACTION_PERFORMED; custom components can generate action events of other types.
The getActionCommand() method returns a String that serves as a kind of name for the action that the event represents. The Button and MenuItem components have a setActionCommand() method that allows the programmer to specify an action command string to be included with any action events generated by those components. It is this value that is returned by the getActionCommand() method. When more than one Button or other component notifies the same ActionListener, you can use getActionCommand() to help determine the appropriate response to the event. This is generally a better technique than using the source object returned by getSource(). If no action command string is explicitly set, getActionCommand() returns the label of the Button or MenuItem. Internationalized programs should not rely on these labels being constant.
getModifiers() returns a value that indicates the keyboard modifiers that were in effect when the action event was triggered. Use the various _MASK constants, along with the & operator, to decode this value.
public class ActionEvent extends AWTEvent { | ||
// | Public Constructors | |
public ActionEvent (Object source, int id, String command); | ||
public ActionEvent (Object source, int id, String command, int modifiers); | ||
// | Public Constants | |
public static final int ACTION_FIRST ; | =1001 | |
public static final int ACTION_LAST ; | =1001 | |
public static final int ACTION_PERFORMED ; | =1001 | |
public static final int ALT_MASK ; | =8 | |
public static final int CTRL_MASK ; | =2 | |
public static final int META_MASK ; | =4 | |
public static final int SHIFT_MASK ; | =1 | |
// | Public Instance Methods | |
public String getActionCommand (); | ||
public int getModifiers (); | ||
// | Public Methods Overriding AWTEvent | |
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->ActionEvent
Passed To: Too many methods to list.
ActionListener | Java 1.1 | |
|
||
java.awt.event | event listener PJ1.1 |
This interface defines the method that an object must implement to listen for action events on AWT components. When an ActionEvent occurs, an AWT component notifies its registered ActionListener objects by invoking their actionPerformed() methods.
public abstract interface ActionListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void actionPerformed (ActionEvent e); | ||
} |
Hierarchy: (ActionListener(java.util.EventListener))
Implementations: AWTEventMulticaster, java.awt.dnd.DropTarget.DropTargetAutoScroller, javax.swing.Action, javax.swing.DefaultCellEditor.EditorDelegate, javax.swing.JComboBox, javax.swing.ToolTipManager.insideTimerAction, javax.swing.ToolTipManager.outsideTimerAction, javax.swing.ToolTipManager.stillInsideTimerAction, javax.swing.text.html.FormView, javax.swing.tree.DefaultTreeCellEditor
Passed To: Too many methods to list.
Returned By: AWTEventMulticaster.{add(), remove()}, javax.swing.AbstractButton.createActionListener(), javax.swing.JComponent.getActionForKeyStroke()
Type Of: javax.swing.AbstractButton.actionListener
AdjustmentEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
An event of this type indicates that an adjustment has been made to an Adjustable object--usually, this means that the user has interacted with a Scrollbar component.
The getValue() method returns the new value of the Adjustable object. This is usually the most important piece of information stored in the event. getAdjustable() returns the Adjustable object that was the source of the event. It is a convenient alternative to the inherited getSource() method.
The getID() method returns the type of an AdjustmentEvent. The standard AWT components only generate adjustment events of the type AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED. There are several types of adjustments that can be made to an Adjustable object, however, and the getAdjustmentType() method returns one of five constants to indicate which type has occurred. UNIT_INCREMENT indicates that the Adjustable value has been incremented by one unit, as in a scroll-line-down operation. UNIT_DECREMENT indicates the opposite: scroll-line-up. BLOCK_INCREMENT and BLOCK_DECREMENT indicate that the Adjustable object has been incremented or decremented by multiple units, as in a scroll-page-down or scroll-page-up operation. Finally, the TRACK constant indicates that the Adjustable value has been set to an absolute value unrelated to its previous value, as when the user drags a scrollbar to a new position.
public class AdjustmentEvent extends AWTEvent { | ||
// | Public Constructors | |
public AdjustmentEvent (Adjustable source, int id, int type, int value); | ||
// | Public Constants | |
public static final int ADJUSTMENT_FIRST ; | =601 | |
public static final int ADJUSTMENT_LAST ; | =601 | |
public static final int ADJUSTMENT_VALUE_CHANGED ; | =601 | |
public static final int BLOCK_DECREMENT ; | =3 | |
public static final int BLOCK_INCREMENT ; | =4 | |
public static final int TRACK ; | =5 | |
public static final int UNIT_DECREMENT ; | =2 | |
public static final int UNIT_INCREMENT ; | =1 | |
// | Public Instance Methods | |
public Adjustable getAdjustable (); | ||
public int getAdjustmentType (); | ||
public int getValue (); | ||
// | Public Methods Overriding AWTEvent | |
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->AdjustmentEvent
Passed To: AWTEventMulticaster.adjustmentValueChanged(), Scrollbar.processAdjustmentEvent(), AdjustmentListener.adjustmentValueChanged()
AdjustmentListener | Java 1.1 | |
|
||
java.awt.event | event listener PJ1.1 |
This interface defines the method that an object must implement to listen for adjustment events on AWT components. When an AdjustmentEvent occurs, an AWT component notifies its registered AdjustmentListener objects by invoking their adjustmentValueChanged() methods.
public abstract interface AdjustmentListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void adjustmentValueChanged (AdjustmentEvent e); | ||
} |
Hierarchy: (AdjustmentListener(java.util.EventListener))
Implementations: AWTEventMulticaster
Passed To: Adjustable.{addAdjustmentListener(), removeAdjustmentListener()}, AWTEventMulticaster.{add(), remove()}, Scrollbar.{addAdjustmentListener(), removeAdjustmentListener()}, javax.swing.JScrollBar.{addAdjustmentListener(), removeAdjustmentListener()}
Returned By: AWTEventMulticaster.{add(), remove()}
AWTEventListener | Java 1.2 | |
|
||
java.awt.event | event listener |
This interface is implemented by objects, such as GUI macro recorders, that want to be notified of all AWT events that occur on Component and MenuComponent objects throughout the system. Register an AWTEventListener with the addAWTEventListener() method of Toolkit.
public abstract interface AWTEventListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void eventDispatched (AWTEvent event); | ||
} |
Hierarchy: (AWTEventListener(java.util.EventListener))
Passed To: Toolkit.{addAWTEventListener(), removeAWTEventListener()}
ComponentAdapter | Java 1.1 | |
|
||
java.awt.event | event adapter PJ1.1 |
This class is a trivial implementation of ComponentListener; it provides empty bodies for each of the methods of that interface. When you are not interested in all of these methods, it is often easier to subclass ComponentAdapter than it is to implement ComponentListener from scratch.
public abstract class ComponentAdapter implements ComponentListener { | ||
// | Public Constructors | |
public ComponentAdapter (); | ||
// | Methods Implementing ComponentListener | |
public void componentHidden (ComponentEvent e); | empty | |
public void componentMoved (ComponentEvent e); | empty | |
public void componentResized (ComponentEvent e); | empty | |
public void componentShown (ComponentEvent e); | empty | |
} |
Hierarchy: Object-->ComponentAdapter(ComponentListener(java.util.EventListener))
Subclasses: javax.swing.JViewport.ViewListener
ComponentEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
An event of this type serves as notification that the source Component has been moved, resized, shown, or hidden. Note that this event is a notification only: the AWT handles these Component operations internally, and the recipient of the event need take no action itself.
getComponent() returns the component that was moved, resized, shown, or hidden. It is simply a convenient alternative to getSource(). getID() returns one of four COMPONENT_ constants to indicate what operation was performed on the Component.
public class ComponentEvent extends AWTEvent { | ||
// | Public Constructors | |
public ComponentEvent (Component source, int id); | ||
// | Public Constants | |
public static final int COMPONENT_FIRST ; | =100 | |
public static final int COMPONENT_HIDDEN ; | =103 | |
public static final int COMPONENT_LAST ; | =103 | |
public static final int COMPONENT_MOVED ; | =100 | |
public static final int COMPONENT_RESIZED ; | =101 | |
public static final int COMPONENT_SHOWN ; | =102 | |
// | Public Instance Methods | |
public Component getComponent (); | ||
// | Public Methods Overriding AWTEvent | |
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->ComponentEvent
Subclasses: ContainerEvent, FocusEvent, InputEvent, PaintEvent, WindowEvent
Passed To: AWTEventMulticaster.{componentHidden(), componentMoved(), componentResized(), componentShown()}, Component.processComponentEvent(), ComponentAdapter.{componentHidden(), componentMoved(), componentResized(), componentShown()}, ComponentListener.{componentHidden(), componentMoved(), componentResized(), componentShown()}, javax.swing.JViewport.ViewListener.componentResized()
ComponentListener | Java 1.1 | |
|
||
java.awt.event | event listener PJ1.1 |
This interface defines the methods that an object must implement to listen for component events on AWT components. When a ComponentEvent occurs, an AWT component notifies its registered ComponentListener objects by invoking one of their methods. An easy way to implement this interface is by subclassing the ComponentAdapter class.
public abstract interface ComponentListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void componentHidden (ComponentEvent e); | ||
public abstract void componentMoved (ComponentEvent e); | ||
public abstract void componentResized (ComponentEvent e); | ||
public abstract void componentShown (ComponentEvent e); | ||
} |
Hierarchy: (ComponentListener(java.util.EventListener))
Implementations: AWTEventMulticaster, ComponentAdapter
Passed To: AWTEventMulticaster.{add(), remove()}, Component.{addComponentListener(), removeComponentListener()}
Returned By: AWTEventMulticaster.{add(), remove()}
ContainerAdapter | Java 1.1 | |
|
||
java.awt.event | event adapter PJ1.1 |
This class is a trivial implementation of ContainerListener; it provides empty bodies for each of the methods of that interface. When you are not interested in all of these methods, it is often easier to subclass ContainerAdapter than it is to implement ContainerListener from scratch.
public abstract class ContainerAdapter implements ContainerListener { | ||
// | Public Constructors | |
public ContainerAdapter (); | ||
// | Methods Implementing ContainerListener | |
public void componentAdded (ContainerEvent e); | empty | |
public void componentRemoved (ContainerEvent e); | empty | |
} |
Hierarchy: Object-->ContainerAdapter(ContainerListener(java.util.EventListener))
ContainerEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
An event of this type serves as notification that the source Container has had a child added to it or removed from it. Note that this event is a notification only; the AWT adds or removes the child internally, and the recipient of this event need take no action itself.
getChild() returns the child Component that was added or removed, and getContainer() returns the Container to which it was added or from which it was removed. getContainer() is simply a convenient alternative to getSource(). getID() returns the constant COMPONENT_ADDED or COMPONENT_REMOVED to indicate whether the specified child was added or removed.
public class ContainerEvent extends ComponentEvent { | ||
// | Public Constructors | |
public ContainerEvent (Component source, int id, Component child); | ||
// | Public Constants | |
public static final int COMPONENT_ADDED ; | =300 | |
public static final int COMPONENT_REMOVED ; | =301 | |
public static final int CONTAINER_FIRST ; | =300 | |
public static final int CONTAINER_LAST ; | =301 | |
// | Public Instance Methods | |
public Component getChild (); | ||
public Container getContainer (); | ||
// | Public Methods Overriding ComponentEvent | |
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->ComponentEvent-->ContainerEvent
Passed To: AWTEventMulticaster.{componentAdded(), componentRemoved()}, Container.processContainerEvent(), ContainerAdapter.{componentAdded(), componentRemoved()}, ContainerListener.{componentAdded(), componentRemoved()}, javax.swing.JComponent.AccessibleJComponent.AccessibleContainerHandler.{componentAdded(), componentRemoved()}
ContainerListener | Java 1.1 | |
|
||
java.awt.event | event listener PJ1.1 |
This interface defines the methods that an object must implement to listen for container events on AWT components. When a ContainerEvent occurs, an AWT component notifies its registered ContainerListener objects by invoking one of their methods. An easy way to implement this interface is by subclassing the ContainerAdapter class.
public abstract interface ContainerListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void componentAdded (ContainerEvent e); | ||
public abstract void componentRemoved (ContainerEvent e); | ||
} |
Hierarchy: (ContainerListener(java.util.EventListener))
Implementations: AWTEventMulticaster, ContainerAdapter, javax.swing.JComponent.AccessibleJComponent.AccessibleContainerHandler
Passed To: AWTEventMulticaster.{add(), remove()}, Container.{addContainerListener(), removeContainerListener()}
Returned By: AWTEventMulticaster.{add(), remove()}
Type Of: javax.swing.JComponent.AccessibleJComponent.accessibleContainerHandler
FocusAdapter | Java 1.1 | |
|
||
java.awt.event | event adapter PJ1.1 |
This class is a trivial implementation of FocusListener; it provides empty bodies for each of the methods of that interface. When you are not interested in all of these methods, it is often easier to subclass FocusAdapter than it is to implement FocusListener from scratch.
public abstract class FocusAdapter implements FocusListener { | ||
// | Public Constructors | |
public FocusAdapter (); | ||
// | Methods Implementing FocusListener | |
public void focusGained (FocusEvent e); | empty | |
public void focusLost (FocusEvent e); | empty | |
} |
Hierarchy: Object-->FocusAdapter(FocusListener(java.util.EventListener))
FocusEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
An event of this type indicates that a Component has gained or lost focus on a temporary or permanent basis. Use the inherited getComponent() method to determine which component has gained or lost focus. Use getID() to determine the type of focus event; it returns FOCUS_GAINED or FOCUS_LOST.
When focus is lost, you can call isTemporary() to determine whether it is a temporary loss of focus. Temporary focus loss occurs when the window that contains the component loses focus, for example, or when focus is temporarily diverted to a popup menu or a scrollbar. Similarly, you can also use isTemporary() to determine whether focus is being granted to a component on a temporary basis.
public class FocusEvent extends ComponentEvent { | ||
// | Public Constructors | |
public FocusEvent (Component source, int id); | ||
public FocusEvent (Component source, int id, boolean temporary); | ||
// | Public Constants | |
public static final int FOCUS_FIRST ; | =1004 | |
public static final int FOCUS_GAINED ; | =1004 | |
public static final int FOCUS_LAST ; | =1005 | |
public static final int FOCUS_LOST ; | =1005 | |
// | Public Instance Methods | |
public boolean isTemporary (); | ||
// | Public Methods Overriding ComponentEvent | |
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->ComponentEvent-->FocusEvent
Passed To: AWTEventMulticaster.{focusGained(), focusLost()}, Component.processFocusEvent(), FocusAdapter.{focusGained(), focusLost()}, FocusListener.{focusGained(), focusLost()}, javax.swing.JComponent.processFocusEvent(), javax.swing.text.DefaultCaret.{focusGained(), focusLost()}
FocusListener | Java 1.1 | |
|
||
java.awt.event | event listener PJ1.1 |
This interface defines the methods that an object must implement to listen for focus events on AWT components. When a FocusEvent occurs, an AWT component notifies its registered FocusListener objects by invoking one of their methods. An easy way to implement this interface is by subclassing the FocusAdapter class.
public abstract interface FocusListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void focusGained (FocusEvent e); | ||
public abstract void focusLost (FocusEvent e); | ||
} |
Hierarchy: (FocusListener(java.util.EventListener))
Implementations: AWTEventMulticaster, FocusAdapter, javax.swing.text.DefaultCaret
Passed To: Too many methods to list.
Returned By: AWTEventMulticaster.{add(), remove()}
InputEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
This abstract class serves as the superclass for the raw user input event types MouseEvent and KeyEvent. Use the inherited getComponent() method to determine in which component the event occurred. Use getWhen() to obtain a timestamp for the event. Use getModifiers() to determine which keyboard modifier keys or mouse buttons were down when the event occurred. You can decode the getModifiers() return value using the various _MASK constants defined by this class. The class also defines four convenience methods for determining the state of keyboard modifiers.
As of Java 1.1, input events are delivered to the appropriate listener objects before they are delivered to the AWT components themselves. If a listener calls the consume() method of the event, the event is not passed on to the component. For example, if a listener registered on a Button consumes a mouse click, it prevents the button itself from responding to that event. You can use isConsumed() to test whether some other listener object has already consumed the event.
public abstract class InputEvent extends ComponentEvent { | ||
// | No Constructor | |
// | Public Constants | |
1.2 | public static final int ALT_GRAPH_MASK ; | =32 |
public static final int ALT_MASK ; | =8 | |
public static final int BUTTON1_MASK ; | =16 | |
public static final int BUTTON2_MASK ; | =8 | |
public static final int BUTTON3_MASK ; | =4 | |
public static final int CTRL_MASK ; | =2 | |
public static final int META_MASK ; | =4 | |
public static final int SHIFT_MASK ; | =1 | |
// | Property Accessor Methods (by property name) | |
public boolean isAltDown (); | ||
1.2 | public boolean isAltGraphDown (); | |
public boolean isConsumed (); | Overrides:AWTEvent | |
public boolean isControlDown (); | ||
public boolean isMetaDown (); | ||
public int getModifiers (); | ||
public boolean isShiftDown (); | ||
public long getWhen (); | ||
// | Public Methods Overriding AWTEvent | |
public void consume (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->ComponentEvent-->InputEvent
Subclasses: KeyEvent, MouseEvent
Passed To: java.awt.dnd.DragGestureRecognizer.appendEvent()
Returned By: java.awt.dnd.DragGestureEvent.getTriggerEvent(), java.awt.dnd.DragGestureRecognizer.getTriggerEvent()
InputMethodEvent | Java 1.2 | |
|
||
java.awt.event | serializable event |
Events of this type are sent from an input method to the text input component or text composition window that is using the services of the input method. An InputMethodEvent is generated each time the user makes an edit to the text that is being composed. Input method details are usually hidden by text input components. Application-level code should never have to use this class.
The getText() method returns a java.text.AttributedCharacterIterator that contains the current input method text. getCommittedCharacterCount() specifies how many characters of that text have been fully composed and committed, so that they are ready to be integrated into the text input component. The input method does not send these committed characters again. Any characters returned by the iterator beyond the specified number of committed characters are characters that are still undergoing composition and are not ready to be integrated into the text input component. These characters may be repeated in future InputMethodEvent objects, as the user continues to edit them.
public class InputMethodEvent extends AWTEvent { | ||
// | Public Constructors | |
public InputMethodEvent (Component source, int id, java.awt.font.TextHitInfo caret, java.awt.font.TextHitInfo visiblePosition); | ||
public InputMethodEvent (Component source, int id, java.text.AttributedCharacterIterator text, int committedCharacterCount, java.awt.font.TextHitInfo caret, java.awt.font.TextHitInfo visiblePosition); | ||
// | Public Constants | |
public static final int CARET_POSITION_CHANGED ; | =1101 | |
public static final int INPUT_METHOD_FIRST ; | =1100 | |
public static final int INPUT_METHOD_LAST ; | =1101 | |
public static final int INPUT_METHOD_TEXT_CHANGED ; | =1100 | |
// | Property Accessor Methods (by property name) | |
public java.awt.font.TextHitInfo getCaret (); | ||
public int getCommittedCharacterCount (); | ||
public boolean isConsumed (); | Overrides:AWTEvent | |
public java.text.AttributedCharacterIterator getText (); | ||
public java.awt.font.TextHitInfo getVisiblePosition (); | ||
// | Public Methods Overriding AWTEvent | |
public void consume (); | ||
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->InputMethodEvent
Passed To: AWTEventMulticaster.{caretPositionChanged(), inputMethodTextChanged()}, Component.processInputMethodEvent(), InputMethodListener.{caretPositionChanged(), inputMethodTextChanged()}, javax.swing.text.JTextComponent.processInputMethodEvent()
InputMethodListener | Java 1.2 | |
|
||
java.awt.event | event listener |
This interface defines the methods that a text input component must define in order to receive notifications from an input method. caretPositionChanged() is invoked when the user has moved the editing cursor. inputMethodTextChanged() is invoked when the user has edited text being composed by the input method.
Input method details are usually hidden by text input components. Application-level code should never have to use or implement this interface.
public abstract interface InputMethodListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void caretPositionChanged (InputMethodEvent event); | ||
public abstract void inputMethodTextChanged (InputMethodEvent event); | ||
} |
Hierarchy: (InputMethodListener(java.util.EventListener))
Implementations: AWTEventMulticaster
Passed To: AWTEventMulticaster.{add(), remove()}, Component.{addInputMethodListener(), removeInputMethodListener()}, javax.swing.text.JTextComponent.addInputMethodListener()
Returned By: AWTEventMulticaster.{add(), remove()}
InvocationEvent | Java 1.2 | |
|
||
java.awt.event | serializable event |
An event of this type is not generated by an asynchronous external event, such as user input. Instead, an InvocationEvent is placed on the event queue by the invokeLater() and invokeAndWait() methods of EventQueue. InvocationEvent implements java.awt.ActiveEvent, which means that it is an event that knows how to dispatch itself, with its own dispatch() method. When an InvocationEvent reaches the front of the event queue, its dispatch() method is called, and this invokes the run() method of the Runnable object specified when the InvocationEvent was created. This technique provides a simple method for running arbitrary code from the event dispatch thread.
Applications need not be concerned with these details; they can simply use the invokeLater() and invokeAndWait() methods of EventQueue.
public class InvocationEvent extends AWTEvent implements ActiveEvent { | ||
// | Public Constructors | |
public InvocationEvent (Object source, Runnable runnable); | ||
public InvocationEvent (Object source, Runnable runnable, Object notifier, boolean catchExceptions); | ||
// | Protected Constructors | |
protected InvocationEvent (Object source, int id, Runnable runnable, Object notifier, boolean catchExceptions); | ||
// | Public Constants | |
public static final int INVOCATION_DEFAULT ; | =1200 | |
public static final int INVOCATION_FIRST ; | =1200 | |
public static final int INVOCATION_LAST ; | =1200 | |
// | Public Instance Methods | |
public Exception getException (); | ||
// | Methods Implementing ActiveEvent | |
public void dispatch (); | ||
// | Public Methods Overriding AWTEvent | |
public String paramString (); | ||
// | Protected Instance Fields | |
protected boolean catchExceptions ; | ||
protected Object notifier ; | ||
protected Runnable runnable ; | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->InvocationEvent(ActiveEvent)
ItemEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
An event of this type indicates that an item within an ItemSelectable component has had its selection state changed. getItemSelectable() is a convenient alternative to getSource() that returns the ItemSelectable object that originated the event. getItem() returns an object that represents the item that was selected or deselected.
getID() returns the type of the ItemEvent. The standard AWT components always generate item events of type ITEM_STATE_CHANGED. The getStateChange() method returns the new selection state of the item: it returns one of the constants SELECTED or DESELECTED. (This value can be misleading for Checkbox components that are part of a CheckboxGroup. If the user attempts to deselect a selected component, a DESELECTED event is delivered, but the CheckboxGroup immediately reselects the component to enforce its requirement that at least one Checkbox be selected at all times.)
public class ItemEvent extends AWTEvent { | ||
// | Public Constructors | |
public ItemEvent (ItemSelectable source, int id, Object item, int stateChange); | ||
// | Public Constants | |
public static final int DESELECTED ; | =2 | |
public static final int ITEM_FIRST ; | =701 | |
public static final int ITEM_LAST ; | =701 | |
public static final int ITEM_STATE_CHANGED ; | =701 | |
public static final int SELECTED ; | =1 | |
// | Public Instance Methods | |
public Object getItem (); | ||
public ItemSelectable getItemSelectable (); | ||
public int getStateChange (); | ||
// | Public Methods Overriding AWTEvent | |
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->ItemEvent
Passed To: AWTEventMulticaster.itemStateChanged(), Checkbox.processItemEvent(), CheckboxMenuItem.processItemEvent(), Choice.processItemEvent(), java.awt.List.processItemEvent(), ItemListener.itemStateChanged(), javax.swing.AbstractButton.fireItemStateChanged(), javax.swing.DefaultButtonModel.fireItemStateChanged(), javax.swing.DefaultCellEditor.EditorDelegate.itemStateChanged(), javax.swing.JComboBox.fireItemStateChanged(), javax.swing.JToggleButton.AccessibleJToggleButton.itemStateChanged()
ItemListener | Java 1.1 | |
|
||
java.awt.event | event listener PJ1.1 |
This interface defines the method that an object must implement to listen for item events on AWT components. When an ItemEvent occurs, an AWT component notifies its registered ItemListener objects by invoking their itemStateChanged() methods.
public abstract interface ItemListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void itemStateChanged (ItemEvent e); | ||
} |
Hierarchy: (ItemListener(java.util.EventListener))
Implementations: AWTEventMulticaster, javax.swing.DefaultCellEditor.EditorDelegate, javax.swing.JToggleButton.AccessibleJToggleButton
Passed To: Too many methods to list.
Returned By: AWTEventMulticaster.{add(), remove()}, javax.swing.AbstractButton.createItemListener()
Type Of: javax.swing.AbstractButton.itemListener
KeyAdapter | Java 1.1 | |
|
||
java.awt.event | event adapter PJ1.1 |
This class is a trivial implementation of KeyListener; it provides empty bodies for each of the methods of that interface. When you are not interested in all of these methods, it is often easier to subclass KeyAdapter than it is to implement KeyListener from scratch.
public abstract class KeyAdapter implements KeyListener { | ||
// | Public Constructors | |
public KeyAdapter (); | ||
// | Methods Implementing KeyListener | |
public void keyPressed (KeyEvent e); | empty | |
public void keyReleased (KeyEvent e); | empty | |
public void keyTyped (KeyEvent e); | empty | |
} |
Hierarchy: Object-->KeyAdapter(KeyListener(java.util.EventListener))
KeyEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
An event of this type indicates that the user has pressed or released a key on the keyboard. Call getID() to determine the particular type of key event that has occurred. The constant KEY_PRESSED indicates that a key has been pressed, while the constant KEY_RELEASED indicates that a key has been released. Not all keystrokes actually correspond to or generate Unicode characters. Modifier keys and function keys, for example, do not correspond to characters. Furthermore, for internationalized input, multiple keystrokes are sometimes required to generate a single character of input. Therefore, getID() returns a third constant, KEY_TYPED, to indicate a KeyEvent that actually contains a character value.
For KEY_PRESSED and KEY_RELEASED key events, use getKeyCode() to obtain the virtual keycode of the key that was pressed or released. KeyEvent defines a number of VK_ constants that represent these virtual keys. Note that not all keys on all keyboards have corresponding constants in the KeyEvent class, and not all keyboards can generate all of the virtual keycodes defined by this class. As of Java 1.1, the VK_ constants for letter keys, number keys, and some other keys have the same values as the ASCII encodings of the letters and numbers. You should not rely on this to always be the case, however. If the key that was pressed or released corresponds directly to a Unicode character, you can obtain that character by calling getKeyChar(). If there is not a corresponding Unicode character, this method returns the constant CHAR_UNDEFINED. The isActionKey() method returns true if the key that was pressed or released does not have a corresponding character.
For KEY_TYPED key events, use getKeyChar() to return the Unicode character that was typed. If you call getKeyCode() for this type of key event, it returns VK_UNDEFINED.
See InputEvent for information on inherited methods you can use to obtain the keyboard modifiers that were down during the event and other important methods. Use getComponent(), inherited from ComponentEvent, to determine over what component the event occurred. The static method getKeyText() returns a (possibly localized) textual name for a given keycode. The static method getKeyModifiersText() returns a (possibly localized) textual description for a set of modifiers.
KeyEvent has methods that allow you to change the keycode, key character, or modifiers of an event. These methods, along with the consume() method, allow a KeyListener to perform filtering of key events before they are passed to the underlying AWT component.
public class KeyEvent extends InputEvent { | ||
// | Public Constructors | |
public KeyEvent (Component source, int id, long when, int modifiers, int keyCode); | ||
public KeyEvent (Component source, int id, long when, int modifiers, int keyCode, char keyChar); | ||
// | Public Constants | |
public static final char CHAR_UNDEFINED ; | ='\uFFFF' | |
public static final int KEY_FIRST ; | =400 | |
public static final int KEY_LAST ; | =402 | |
public static final int KEY_PRESSED ; | =401 | |
public static final int KEY_RELEASED ; | =402 | |
public static final int KEY_TYPED ; | =400 | |
public static final int VK_0 ; | =48 | |
public static final int VK_1 ; | =49 | |
public static final int VK_2 ; | =50 | |
public static final int VK_3 ; | =51 | |
public static final int VK_4 ; | =52 | |
public static final int VK_5 ; | =53 | |
public static final int VK_6 ; | =54 | |
public static final int VK_7 ; | =55 | |
public static final int VK_8 ; | =56 | |
public static final int VK_9 ; | =57 | |
public static final int VK_A ; | =65 | |
public static final int VK_ACCEPT ; | =30 | |
public static final int VK_ADD ; | =107 | |
1.2 | public static final int VK_AGAIN ; | =65481 |
1.2 | public static final int VK_ALL_CANDIDATES ; | =256 |
1.2 | public static final int VK_ALPHANUMERIC ; | =240 |
public static final int VK_ALT ; | =18 | |
1.2 | public static final int VK_ALT_GRAPH ; | =65406 |
1.2 | public static final int VK_AMPERSAND ; | =150 |
1.2 | public static final int VK_ASTERISK ; | =151 |
1.2 | public static final int VK_AT ; | =512 |
public static final int VK_B ; | =66 | |
public static final int VK_BACK_QUOTE ; | =192 | |
public static final int VK_BACK_SLASH ; | =92 | |
public static final int VK_BACK_SPACE ; | =8 | |
1.2 | public static final int VK_BRACELEFT ; | =161 |
1.2 | public static final int VK_BRACERIGHT ; | =162 |
public static final int VK_C ; | =67 | |
public static final int VK_CANCEL ; | =3 | |
public static final int VK_CAPS_LOCK ; | =20 | |
1.2 | public static final int VK_CIRCUMFLEX ; | =514 |
public static final int VK_CLEAR ; | =12 | |
public static final int VK_CLOSE_BRACKET ; | =93 | |
1.2 | public static final int VK_CODE_INPUT ; | =258 |
1.2 | public static final int VK_COLON ; | =513 |
public static final int VK_COMMA ; | =44 | |
1.2 | public static final int VK_COMPOSE ; | =65312 |
public static final int VK_CONTROL ; | =17 | |
public static final int VK_CONVERT ; | =28 | |
1.2 | public static final int VK_COPY ; | =65485 |
1.2 | public static final int VK_CUT ; | =65489 |
public static final int VK_D ; | =68 | |
1.2 | public static final int VK_DEAD_ABOVEDOT ; | =134 |
1.2 | public static final int VK_DEAD_ABOVERING ; | =136 |
1.2 | public static final int VK_DEAD_ACUTE ; | =129 |
1.2 | public static final int VK_DEAD_BREVE ; | =133 |
1.2 | public static final int VK_DEAD_CARON ; | =138 |
1.2 | public static final int VK_DEAD_CEDILLA ; | =139 |
1.2 | public static final int VK_DEAD_CIRCUMFLEX ; | =130 |
1.2 | public static final int VK_DEAD_DIAERESIS ; | =135 |
1.2 | public static final int VK_DEAD_DOUBLEACUTE ; | =137 |
1.2 | public static final int VK_DEAD_GRAVE ; | =128 |
1.2 | public static final int VK_DEAD_IOTA ; | =141 |
1.2 | public static final int VK_DEAD_MACRON ; | =132 |
1.2 | public static final int VK_DEAD_OGONEK ; | =140 |
1.2 | public static final int VK_DEAD_SEMIVOICED_SOUND ; | =143 |
1.2 | public static final int VK_DEAD_TILDE ; | =131 |
1.2 | public static final int VK_DEAD_VOICED_SOUND ; | =142 |
public static final int VK_DECIMAL ; | =110 | |
public static final int VK_DELETE ; | =127 | |
public static final int VK_DIVIDE ; | =111 | |
1.2 | public static final int VK_DOLLAR ; | =515 |
public static final int VK_DOWN ; | =40 | |
public static final int VK_E ; | =69 | |
public static final int VK_END ; | =35 | |
public static final int VK_ENTER ; | =10 | |
public static final int VK_EQUALS ; | =61 | |
public static final int VK_ESCAPE ; | =27 | |
1.2 | public static final int VK_EURO_SIGN ; | =516 |
1.2 | public static final int VK_EXCLAMATION_MARK ; | =517 |
public static final int VK_F ; | =70 | |
public static final int VK_F1 ; | =112 | |
public static final int VK_F10 ; | =121 | |
public static final int VK_F11 ; | =122 | |
public static final int VK_F12 ; | =123 | |
1.2 | public static final int VK_F13 ; | =61440 |
1.2 | public static final int VK_F14 ; | =61441 |
1.2 | public static final int VK_F15 ; | =61442 |
1.2 | public static final int VK_F16 ; | =61443 |
1.2 | public static final int VK_F17 ; | =61444 |
1.2 | public static final int VK_F18 ; | =61445 |
1.2 | public static final int VK_F19 ; | =61446 |
public static final int VK_F2 ; | =113 | |
1.2 | public static final int VK_F20 ; | =61447 |
1.2 | public static final int VK_F21 ; | =61448 |
1.2 | public static final int VK_F22 ; | =61449 |
1.2 | public static final int VK_F23 ; | =61450 |
1.2 | public static final int VK_F24 ; | =61451 |
public static final int VK_F3 ; | =114 | |
public static final int VK_F4 ; | =115 | |
public static final int VK_F5 ; | =116 | |
public static final int VK_F6 ; | =117 | |
public static final int VK_F7 ; | =118 | |
public static final int VK_F8 ; | =119 | |
public static final int VK_F9 ; | =120 | |
public static final int VK_FINAL ; | =24 | |
1.2 | public static final int VK_FIND ; | =65488 |
1.2 | public static final int VK_FULL_WIDTH ; | =243 |
public static final int VK_G ; | =71 | |
1.2 | public static final int VK_GREATER ; | =160 |
public static final int VK_H ; | =72 | |
1.2 | public static final int VK_HALF_WIDTH ; | =244 |
public static final int VK_HELP ; | =156 | |
1.2 | public static final int VK_HIRAGANA ; | =242 |
public static final int VK_HOME ; | =36 | |
public static final int VK_I ; | =73 | |
public static final int VK_INSERT ; | =155 | |
1.2 | public static final int VK_INVERTED_EXCLAMATION_MARK ; | =518 |
public static final int VK_J ; | =74 | |
1.2 | public static final int VK_JAPANESE_HIRAGANA ; | =260 |
1.2 | public static final int VK_JAPANESE_KATAKANA ; | =259 |
1.2 | public static final int VK_JAPANESE_ROMAN ; | =261 |
public static final int VK_K ; | =75 | |
public static final int VK_KANA ; | =21 | |
public static final int VK_KANJI ; | =25 | |
1.2 | public static final int VK_KATAKANA ; | =241 |
1.2 | public static final int VK_KP_DOWN ; | =225 |
1.2 | public static final int VK_KP_LEFT ; | =226 |
1.2 | public static final int VK_KP_RIGHT ; | =227 |
1.2 | public static final int VK_KP_UP ; | =224 |
public static final int VK_L ; | =76 | |
public static final int VK_LEFT ; | =37 | |
1.2 | public static final int VK_LEFT_PARENTHESIS ; | =519 |
1.2 | public static final int VK_LESS ; | =153 |
public static final int VK_M ; | =77 | |
public static final int VK_META ; | =157 | |
1.2 | public static final int VK_MINUS ; | =45 |
public static final int VK_MODECHANGE ; | =31 | |
public static final int VK_MULTIPLY ; | =106 | |
public static final int VK_N ; | =78 | |
public static final int VK_NONCONVERT ; | =29 | |
public static final int VK_NUM_LOCK ; | =144 | |
1.2 | public static final int VK_NUMBER_SIGN ; | =520 |
public static final int VK_NUMPAD0 ; | =96 | |
public static final int VK_NUMPAD1 ; | =97 | |
public static final int VK_NUMPAD2 ; | =98 | |
public static final int VK_NUMPAD3 ; | =99 | |
public static final int VK_NUMPAD4 ; | =100 | |
public static final int VK_NUMPAD5 ; | =101 | |
public static final int VK_NUMPAD6 ; | =102 | |
public static final int VK_NUMPAD7 ; | =103 | |
public static final int VK_NUMPAD8 ; | =104 | |
public static final int VK_NUMPAD9 ; | =105 | |
public static final int VK_O ; | =79 | |
public static final int VK_OPEN_BRACKET ; | =91 | |
public static final int VK_P ; | =80 | |
public static final int VK_PAGE_DOWN ; | =34 | |
public static final int VK_PAGE_UP ; | =33 | |
1.2 | public static final int VK_PASTE ; | =65487 |
public static final int VK_PAUSE ; | =19 | |
public static final int VK_PERIOD ; | =46 | |
1.2 | public static final int VK_PLUS ; | =521 |
1.2 | public static final int VK_PREVIOUS_CANDIDATE ; | =257 |
public static final int VK_PRINTSCREEN ; | =154 | |
1.2 | public static final int VK_PROPS ; | =65482 |
public static final int VK_Q ; | =81 | |
public static final int VK_QUOTE ; | =222 | |
1.2 | public static final int VK_QUOTEDBL ; | =152 |
public static final int VK_R ; | =82 | |
public static final int VK_RIGHT ; | =39 | |
1.2 | public static final int VK_RIGHT_PARENTHESIS ; | =522 |
1.2 | public static final int VK_ROMAN_CHARACTERS ; | =245 |
public static final int VK_S ; | =83 | |
public static final int VK_SCROLL_LOCK ; | =145 | |
public static final int VK_SEMICOLON ; | =59 | |
public static final int VK_SEPARATER ; | =108 | |
public static final int VK_SHIFT ; | =16 | |
public static final int VK_SLASH ; | =47 | |
public static final int VK_SPACE ; | =32 | |
1.2 | public static final int VK_STOP ; | =65480 |
public static final int VK_SUBTRACT ; | =109 | |
public static final int VK_T ; | =84 | |
public static final int VK_TAB ; | =9 | |
public static final int VK_U ; | =85 | |
public static final int VK_UNDEFINED ; | =0 | |
1.2 | public static final int VK_UNDERSCORE ; | =523 |
1.2 | public static final int VK_UNDO ; | =65483 |
public static final int VK_UP ; | =38 | |
public static final int VK_V ; | =86 | |
public static final int VK_W ; | =87 | |
public static final int VK_X ; | =88 | |
public static final int VK_Y ; | =89 | |
public static final int VK_Z ; | =90 | |
// | Public Class Methods | |
public static String getKeyModifiersText (int modifiers); | ||
public static String getKeyText (int keyCode); | ||
// | Property Accessor Methods (by property name) | |
public boolean isActionKey (); | ||
public char getKeyChar (); | ||
public void setKeyChar (char keyChar); | ||
public int getKeyCode (); | ||
public void setKeyCode (int keyCode); | ||
// | Public Instance Methods | |
public void setModifiers (int modifiers); | ||
// | Public Methods Overriding ComponentEvent | |
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->ComponentEvent-->InputEvent-->KeyEvent
Subclasses: javax.swing.event.MenuKeyEvent
Passed To: Too many methods to list.
KeyListener | Java 1.1 | |
|
||
java.awt.event | event listener PJ1.1 |
This interface defines the methods that an object must implement to listen for key events on AWT components. When a KeyEvent occurs, an AWT component notifies its registered KeyListener objects by invoking one of their methods. An easy way to implement this interface is by subclassing the KeyAdapter class.
public abstract interface KeyListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void keyPressed (KeyEvent e); | ||
public abstract void keyReleased (KeyEvent e); | ||
public abstract void keyTyped (KeyEvent e); | ||
} |
Hierarchy: (KeyListener(java.util.EventListener))
Implementations: AWTEventMulticaster, KeyAdapter
Passed To: AWTEventMulticaster.{add(), remove()}, Component.{addKeyListener(), removeKeyListener()}
Returned By: AWTEventMulticaster.{add(), remove()}
MouseAdapter | Java 1.1 | |
|
||
java.awt.event | event adapter PJ1.1 |
This class is a trivial implementation of MouseListener; it provides empty bodies for each of the methods of that interface. When you are not interested in all of these methods, it is often easier to subclass MouseAdapter than it is to implement MouseListener from scratch.
public abstract class MouseAdapter implements MouseListener { | ||
// | Public Constructors | |
public MouseAdapter (); | ||
// | Methods Implementing MouseListener | |
public void mouseClicked (MouseEvent e); | empty | |
public void mouseEntered (MouseEvent e); | empty | |
public void mouseExited (MouseEvent e); | empty | |
public void mousePressed (MouseEvent e); | empty | |
public void mouseReleased (MouseEvent e); | empty | |
} |
Hierarchy: Object-->MouseAdapter(MouseListener(java.util.EventListener))
Subclasses: javax.swing.ToolTipManager, javax.swing.text.html.FormView.MouseEventListener, javax.swing.text.html.HTMLEditorKit.LinkController
MouseEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
An event of this type indicates that the user has moved the mouse or pressed one of the mouse buttons. Call getID() to determine the specific type of mouse event that has occurred. This method returns one of the following seven constants, which corresponds to a method in either the MouseListener or MouseMotionListener interface:
The user has pressed a mouse button.
The user has released a mouse button.
The user has pressed and released a mouse button without any intervening mouse drag.
The user has moved the mouse while holding a button down.
The user has moved the mouse without holding any buttons down.
The mouse pointer has entered the component.
The mouse pointer has left the component.
Use getX() and getY() or getPoint() to obtain the coordinates of the mouse event. Use translatePoint() to modify these coordinates by a specified amount.
Use getModifiers() and other methods and constants inherited from InputEvent to determine the mouse button or keyboard modifiers that were down when the event occurred. See InputEvent for details. Note that mouse button modifiers are not reported for MOUSE_RELEASED events, since, technically, the mouse button in question is no longer pressed.
Use getComponent(), inherited from ComponentEvent, to determine over which component the event occurred. For mouse events of type MOUSE_CLICKED, MOUSE_PRESSED, or MOUSE_RELEASED, call getClickCount() to determine how many consecutive clicks have occurred. If you are using popup menus, use isPopupTrigger() to test whether the current event represents the standard platform-dependent popup menu trigger event.
public class MouseEvent extends InputEvent { | ||
// | Public Constructors | |
public MouseEvent (Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger); | ||
// | Public Constants | |
public static final int MOUSE_CLICKED ; | =500 | |
public static final int MOUSE_DRAGGED ; | =506 | |
public static final int MOUSE_ENTERED ; | =504 | |
public static final int MOUSE_EXITED ; | =505 | |
public static final int MOUSE_FIRST ; | =500 | |
public static final int MOUSE_LAST ; | =506 | |
public static final int MOUSE_MOVED ; | =503 | |
public static final int MOUSE_PRESSED ; | =501 | |
public static final int MOUSE_RELEASED ; | =502 | |
// | Property Accessor Methods (by property name) | |
public int getClickCount (); | ||
public Point getPoint (); | ||
public boolean isPopupTrigger (); | ||
public int getX (); | ||
public int getY (); | ||
// | Public Instance Methods | |
public void translatePoint (int x, int y); | synchronized | |
// | Public Methods Overriding ComponentEvent | |
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->ComponentEvent-->InputEvent-->MouseEvent
Subclasses: javax.swing.event.MenuDragMouseEvent
Passed To: Too many methods to list.
Returned By: javax.swing.SwingUtilities.convertMouseEvent()
MouseListener | Java 1.1 | |
|
||
java.awt.event | event listener PJ1.1 |
This interface defines the methods that an object must implement to listen for mouse events on AWT components. When a MouseEvent occurs, an AWT component notifies its registered MouseListener objects (or MouseMotionListener objects, if the event involves mouse motion) by invoking one of their methods. An easy way to implement this interface is by subclassing the MouseAdapter class.
public abstract interface MouseListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void mouseClicked (MouseEvent e); | ||
public abstract void mouseEntered (MouseEvent e); | ||
public abstract void mouseExited (MouseEvent e); | ||
public abstract void mousePressed (MouseEvent e); | ||
public abstract void mouseReleased (MouseEvent e); | ||
} |
Hierarchy: (MouseListener(java.util.EventListener))
Implementations: AWTEventMulticaster, java.awt.dnd.MouseDragGestureRecognizer, MouseAdapter, javax.swing.event.MouseInputListener, javax.swing.text.DefaultCaret
Passed To: AWTEventMulticaster.{add(), remove()}, Component.{addMouseListener(), removeMouseListener()}
Returned By: AWTEventMulticaster.{add(), remove()}
MouseMotionAdapter | Java 1.1 | |
|
||
java.awt.event | event adapter PJ1.1 |
This class is a trivial implementation of MouseMotionListener; it provides empty bodies for each of the methods of that interface. When you are not interested in all of these methods, it is often easier to subclass MouseMotionAdapter than it is to implement MouseMotionListener from scratch.
public abstract class MouseMotionAdapter implements MouseMotionListener { | ||
// | Public Constructors | |
public MouseMotionAdapter (); | ||
// | Methods Implementing MouseMotionListener | |
public void mouseDragged (MouseEvent e); | empty | |
public void mouseMoved (MouseEvent e); | empty | |
} |
Hierarchy: Object-->MouseMotionAdapter(MouseMotionListener(java.util.EventListener))
MouseMotionListener | Java 1.1 | |
|
||
java.awt.event | event listener PJ1.1 |
This interface defines the methods that an object must implement to listen for mouse motion events on AWT components. When a MouseEvent involving a mouse drag or mouse motion with no buttons down occurs, an AWT component notifies its registered MouseMotionListener objects by invoking one of their methods. An easy way to implement this is by subclassing the MouseMotionAdapter class.
public abstract interface MouseMotionListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void mouseDragged (MouseEvent e); | ||
public abstract void mouseMoved (MouseEvent e); | ||
} |
Hierarchy: (MouseMotionListener(java.util.EventListener))
Implementations: AWTEventMulticaster, java.awt.dnd.MouseDragGestureRecognizer, MouseMotionAdapter, javax.swing.ToolTipManager, javax.swing.event.MouseInputListener, javax.swing.text.DefaultCaret
Passed To: AWTEventMulticaster.{add(), remove()}, Component.{addMouseMotionListener(), removeMouseMotionListener()}
Returned By: AWTEventMulticaster.{add(), remove()}
PaintEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
An event of this type indicates that a component should have its update() method invoked. (The update() method typically, by default, invokes the paint() method.)
PaintEvent differs from the other event types in java.awt.event in that it does not have a corresponding EventListener interface. PaintEvent is essentially for internal use by the AWT redisplay framework, so your programs should not try to handle it the way they handle other events. Instead, applets and custom components should simply override their paint() and/or update() methods to redraw themselves appropriately. AWT automatically invokes update() (which typically invokes paint()) when a PaintEvent arrives.
Although you do not typically use PaintEvent, redraw events are implemented through this class for simplicity, so that they are on equal footing with other event types and so that advanced programs can manipulate them through the EventQueue.
public class PaintEvent extends ComponentEvent { | ||
// | Public Constructors | |
public PaintEvent (Component source, int id, Rectangle updateRect); | ||
// | Public Constants | |
public static final int PAINT ; | =800 | |
public static final int PAINT_FIRST ; | =800 | |
public static final int PAINT_LAST ; | =801 | |
public static final int UPDATE ; | =801 | |
// | Public Instance Methods | |
public Rectangle getUpdateRect (); | ||
public void setUpdateRect (Rectangle updateRect); | ||
// | Public Methods Overriding ComponentEvent | |
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->ComponentEvent-->PaintEvent
TextEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
An event of this type indicates that the user has edited the text value that appears in a TextField, TextArea, or other TextComponent. This event is triggered by any change to the displayed text. Note that this is not the same as the ActionEvent sent by the TextField object when the user edits the text and strikes the Return key.
Use the inherited getSource() to determine the object that was the source of this event. You have to cast that object to its TextComponent type. Call getID() to determine the type of a TextEvent. The standard AWT components always generate text events of type TEXT_VALUE_CHANGED.
public class TextEvent extends AWTEvent { | ||
// | Public Constructors | |
public TextEvent (Object source, int id); | ||
// | Public Constants | |
public static final int TEXT_FIRST ; | =900 | |
public static final int TEXT_LAST ; | =900 | |
public static final int TEXT_VALUE_CHANGED ; | =900 | |
// | Public Methods Overriding AWTEvent | |
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->TextEvent
Passed To: AWTEventMulticaster.textValueChanged(), TextComponent.processTextEvent(), TextListener.textValueChanged()
TextListener | Java 1.1 | |
|
||
java.awt.event | event listener PJ1.1 |
This interface defines the method that an object must implement to listen for text events on AWT components. When a TextEvent occurs, an AWT component notifies its registered TextListener objects by invoking their textValueChanged() methods.
public abstract interface TextListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void textValueChanged (TextEvent e); | ||
} |
Hierarchy: (TextListener(java.util.EventListener))
Implementations: AWTEventMulticaster
Passed To: AWTEventMulticaster.{add(), remove()}, TextComponent.{addTextListener(), removeTextListener()}
Returned By: AWTEventMulticaster.{add(), remove()}
Type Of: TextComponent.textListener
WindowAdapter | Java 1.1 | |
|
||
java.awt.event | event adapter PJ1.1 |
This class is a trivial implementation of WindowListener; it provides empty bodies for each of the methods of that interface. When you are not interested in all of these methods, it is often easier to subclass WindowAdapter than it is to implement WindowListener from scratch.
public abstract class WindowAdapter implements WindowListener { | ||
// | Public Constructors | |
public WindowAdapter (); | ||
// | Methods Implementing WindowListener | |
public void windowActivated (WindowEvent e); | empty | |
public void windowClosed (WindowEvent e); | empty | |
public void windowClosing (WindowEvent e); | empty | |
public void windowDeactivated (WindowEvent e); | empty | |
public void windowDeiconified (WindowEvent e); | empty | |
public void windowIconified (WindowEvent e); | empty | |
public void windowOpened (WindowEvent e); | empty | |
} |
Hierarchy: Object-->WindowAdapter(WindowListener(java.util.EventListener))
Subclasses: javax.swing.JMenu.WinListener
WindowEvent | Java 1.1 | |
|
||
java.awt.event | serializable event PJ1.1 |
An event of this type indicates that an important action has occurred for a Window object. Call getWindow() to determine the Window object that is the source of this event. Call getID() to determine the specific type of event that has occurred. Each of the following seven constants corresponds to one of the methods of the WindowListener interface:
Indicates that the window has been created and opened; it is delivered only the first time that a window is opened.
Indicates that the user has requested that the window be closed through the system menu, through a close button on the window's border, or by invoking a platform-defined keystroke, such as Alt-F4 in Windows. The application should respond to this event by calling hide() or dispose() on the Window object.
Delivered after a window is closed by a call to hide() or dispose().
Delivered when the user iconifies the window.
Delivered when the user deiconifies the window.
Delivered when the window is activated--that is, when it is given the keyboard focus and becomes the active window.
Delivered when the window ceases to be the active window, typically when the user activates some other window.
public class WindowEvent extends ComponentEvent { | ||
// | Public Constructors | |
public WindowEvent (Window source, int id); | ||
// | Public Constants | |
public static final int WINDOW_ACTIVATED ; | =205 | |
public static final int WINDOW_CLOSED ; | =202 | |
public static final int WINDOW_CLOSING ; | =201 | |
public static final int WINDOW_DEACTIVATED ; | =206 | |
public static final int WINDOW_DEICONIFIED ; | =204 | |
public static final int WINDOW_FIRST ; | =200 | |
public static final int WINDOW_ICONIFIED ; | =203 | |
public static final int WINDOW_LAST ; | =206 | |
public static final int WINDOW_OPENED ; | =200 | |
// | Public Instance Methods | |
public Window getWindow (); | ||
// | Public Methods Overriding ComponentEvent | |
public String paramString (); | ||
} |
Hierarchy: Object-->java.util.EventObject(Serializable)-->AWTEvent-->ComponentEvent-->WindowEvent
Passed To: Too many methods to list.
WindowListener | Java 1.1 | |
|
||
java.awt.event | event listener PJ1.1 |
This interface defines the methods that an object must implement to listen for window events on AWT components. When a WindowEvent occurs, an AWT component notifies its registered WindowListener objects by invoking one of their methods. An easy way to implement this interface is by subclassing the WindowAdapter class.
public abstract interface WindowListener extends java.util.EventListener { | ||
// | Public Instance Methods | |
public abstract void windowActivated (WindowEvent e); | ||
public abstract void windowClosed (WindowEvent e); | ||
public abstract void windowClosing (WindowEvent e); | ||
public abstract void windowDeactivated (WindowEvent e); | ||
public abstract void windowDeiconified (WindowEvent e); | ||
public abstract void windowIconified (WindowEvent e); | ||
public abstract void windowOpened (WindowEvent e); | ||
} |
Hierarchy: (WindowListener(java.util.EventListener))
Implementations: AWTEventMulticaster, WindowAdapter
Passed To: AWTEventMulticaster.{add(), remove()}, Window.{addWindowListener(), removeWindowListener()}
Returned By: AWTEventMulticaster.{add(), remove()}
Copyright © 2001 O'Reilly & Associates. All rights reserved.