Book Home Java Enterprise in a Nutshell Search this book

Chapter 26. The javax.swing.event Package

The javax.swing.event package augments the java.awt.event package and defines event objects, listeners, and adapters that are specific to Swing components. Classes with names ending in "Event" define event types; their fields and methods provide details about the event that occurred. Interfaces with names ending in "Listener" are event listeners. The methods of these interfaces are invoked to notify interested objects when specific events occur. Classes with names ending in "Adapter" are convenient no-op implementations of listener interfaces. Typically, it is easier to subclass an adapter class than implement the corresponding listener interface from scratch. Figure 26-1 shows the event classes of this package, while Figure 26-2 shows the event listeners.

figure

Figure 26-1. The events of the javax.swing.event package

figure

Figure 26-2. The event listeners of the javax.swing.event package

AncestorEventJava 1.2
javax.swing.eventserializable event

An event of this type is generated by a JComponent when it is moved, becomes visible, or becomes invisible. Often, the event is generated when one of the component's ancestors is moved, becomes visible, or becomes invisible. The inherited getID() method returns the type of the event, which is one of the constants defined by the class. ANCESTOR_ADDED is used when the component becomes visible, and ANCESTOR_REMOVED is used when the component becomes invisible. getAncestor() returns the ancestor component that was modified, and, as a convenience, getAncestorParent() returns the parent of that ancestor. getComponent() is a synonym for the inherited getSource() method, except that it casts its return value to a JComponent.

public class AncestorEvent extends java.awt.AWTEvent {
// Public Constructors
public AncestorEvent (JComponent source, int id, Container ancestor, Container ancestorParent);
// Public Constants
public static final int ANCESTOR_ADDED ; =1
public static final int ANCESTOR_MOVED ; =3
public static final int ANCESTOR_REMOVED ; =2
// Public Instance Methods
public Container getAncestor ();
public Container getAncestorParent ();
public JComponent getComponent ();
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->java.awt.AWTEvent-->AncestorEvent

Passed To: AncestorListener.{ancestorAdded(), ancestorMoved(), ancestorRemoved()}

AncestorListenerJava 1.2
javax.swing.eventevent listener

This interface defines the methods that must be implemented by an object that wants to receive notification when a JComponent is moved (with ancestorMoved()), made visible (ancestorAdded()),or made invisible (ancestorRemoved()).

public abstract interface AncestorListener extends java.util.EventListener {
// Public Instance Methods
public abstract void ancestorAdded (AncestorEvent event);
public abstract void ancestorMoved (AncestorEvent event);
public abstract void ancestorRemoved (AncestorEvent event);
}

Hierarchy: (AncestorListener(java.util.EventListener))

Passed To: JComponent.{addAncestorListener(), removeAncestorListener()}

CaretEventJava 1.2
javax.swing.eventserializable event

This event is generated by JTextComponent and its subclasses JTextField, JTextArea, JTextPane, and JEditorPane when the caret position changes. The text caret maintains both the current insertion position (the dot) and a marker position (the mark). A CaretEvent is generated when either position changes. The changed values can be obtained with getDot() and getMark(), respectively. The text component that contains the caret can be queried with the inherited getSource() method.

public abstract class CaretEvent extends java.util.EventObject {
// Public Constructors
public CaretEvent (Object source);
// Public Instance Methods
public abstract int getDot ();
public abstract int getMark ();
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->CaretEvent

Passed To: CaretListener.caretUpdate(), javax.swing.text.JTextComponent.fireCaretUpdate(), javax.swing.text.JTextComponent.AccessibleJTextComponent.caretUpdate()

CaretListenerJava 1.2
javax.swing.eventevent listener

This interface defines a method that an object must implement if it wants to receive notification when the caret position changes in a JTextComponent or one of its subclasses.

public abstract interface CaretListener extends java.util.EventListener {
// Public Instance Methods
public abstract void caretUpdate (CaretEvent e);
}

Hierarchy: (CaretListener(java.util.EventListener))

Implementations: javax.swing.text.JTextComponent.AccessibleJTextComponent

Passed To: javax.swing.text.JTextComponent.{addCaretListener(), removeCaretListener()}

CellEditorListenerJava 1.2
javax.swing.eventevent listener

This interface defines the methods that must be implemented by an object that wants to receive notification of state changes in a javax.swing.CellEditor. Note that these methods are passed a ChangeEvent; there is no special CellEditorEvent type.

public abstract interface CellEditorListener extends java.util.EventListener {
// Public Instance Methods
public abstract void editingCanceled (ChangeEvent e);
public abstract void editingStopped (ChangeEvent e);
}

Hierarchy: (CellEditorListener(java.util.EventListener))

Implementations: JTable, JTable.AccessibleJTable

Passed To: CellEditor.{addCellEditorListener(), removeCellEditorListener()}, DefaultCellEditor.{addCellEditorListener(), removeCellEditorListener()}, javax.swing.tree.DefaultTreeCellEditor.{addCellEditorListener(), removeCellEditorListener()}

ChangeEventJava 1.2
javax.swing.eventserializable event

This class is a generic event type that is generated by many Swing components to indicate that something has changed within the component. ChangeEvent does not contain any fields to indicate the type of the change; the type of state change should be implicit in the event listener to which the ChangeEvent object is passed. The only state maintained by ChangeEvent is the component that generated the event (returned by the inherited getSource() method). Because ChangeEvent is immutable and effectively stateless, Swing components can reuse a single shared ChangeEvent object for all their state changes, instead of allocating an event object for every change.

public class ChangeEvent extends java.util.EventObject {
// Public Constructors
public ChangeEvent (Object source);
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->ChangeEvent

Passed To: Too many methods to list.

Type Of: AbstractButton.changeEvent, DefaultBoundedRangeModel.changeEvent, DefaultButtonModel.changeEvent, DefaultCellEditor.changeEvent, DefaultSingleSelectionModel.changeEvent, JProgressBar.changeEvent, JSlider.changeEvent, JTabbedPane.changeEvent, MenuSelectionManager.changeEvent, javax.swing.colorchooser.DefaultColorSelectionModel.changeEvent, javax.swing.table.DefaultTableColumnModel.changeEvent, javax.swing.text.DefaultCaret.changeEvent, javax.swing.text.StyleContext.NamedStyle.changeEvent

ChangeListenerJava 1.2
javax.swing.eventevent listener

This interface defines the method that an object must implement to receive notifications of state change events in Swing components.

public abstract interface ChangeListener extends java.util.EventListener {
// Public Instance Methods
public abstract void stateChanged (ChangeEvent e);
}

Hierarchy: (ChangeListener(java.util.EventListener))

Implementations: AbstractButton.ButtonChangeListener, JMenuItem.AccessibleJMenuItem, JScrollPane.AccessibleJScrollPane, JTabbedPane.AccessibleJTabbedPane, JTabbedPane.ModelListener

Passed To: Too many methods to list.

Returned By: AbstractButton.createChangeListener(), JProgressBar.createChangeListener(), JSlider.createChangeListener(), JTabbedPane.createChangeListener()

Type Of: AbstractButton.changeListener, JProgressBar.changeListener, JSlider.changeListener, JTabbedPane.changeListener

DocumentEventJava 1.2
javax.swing.event

Events of this type are generated by a javax.swing.text.Document object when the document it represents changes. getDocument() returns the Document that was modified. getType() returns the type of the changes; its return value is one of the three constants defined by the DocumentEvent.EventType inner class. getOffset() returns the document coordinate of the start of the change, and getLength() returns the length of the change. getChange() returns a DocumentEvent.ElementChange object that describes the change in terms of its effect on the specified javax.swing.text.Element of the document.

public abstract interface DocumentEvent {
// Inner Classes
;
;
// Property Accessor Methods (by property name)
public abstract javax.swing.text.Document getDocument ();
public abstract int getLength ();
public abstract int getOffset ();
public abstract DocumentEvent.EventType getType ();
// Public Instance Methods
public abstract DocumentEvent.ElementChange getChange (javax.swing.text.Element elem);
}

Implementations: javax.swing.text.AbstractDocument.DefaultDocumentEvent

Passed To: Too many methods to list.

DocumentEvent.ElementChangeJava 1.2
javax.swing.event

This interface defines methods that provide information about changes to an javax.swing.text.Element object within a javax.swing.text.Document.

public abstract static interface DocumentEvent.ElementChange {
// Property Accessor Methods (by property name)
public abstract javax.swing.text.Element[ ] getChildrenAdded ();
public abstract javax.swing.text.Element[ ] getChildrenRemoved ();
public abstract javax.swing.text.Element getElement ();
public abstract int getIndex ();
}

Implementations: javax.swing.text.AbstractDocument.ElementEdit

Returned By: DocumentEvent.getChange(), javax.swing.text.AbstractDocument.DefaultDocumentEvent.getChange()

DocumentEvent.EventTypeJava 1.2
javax.swing.event

This class defines three type-safe object constants that are used to specify the type of a DocumentEvent.

public static final class DocumentEvent.EventType {
// No Constructor
// Public Constants
public static final DocumentEvent.EventType CHANGE ;
public static final DocumentEvent.EventType INSERT ;
public static final DocumentEvent.EventType REMOVE ;
// Public Methods Overriding Object
public String toString ();
}

Passed To: javax.swing.text.AbstractDocument.DefaultDocumentEvent.DefaultDocumentEvent()

Returned By: DocumentEvent.getType(), javax.swing.text.AbstractDocument.DefaultDocumentEvent.getType()

Type Of: DocumentEvent.EventType.{CHANGE, INSERT, REMOVE}

DocumentListenerJava 1.2
javax.swing.eventevent listener

This interface defines the method that an object must implement in order to register for notifications of changes to a javax.swing.text.Document object.

public abstract interface DocumentListener extends java.util.EventListener {
// Public Instance Methods
public abstract void changedUpdate (DocumentEvent e);
public abstract void insertUpdate (DocumentEvent e);
public abstract void removeUpdate (DocumentEvent e);
}

Hierarchy: (DocumentListener(java.util.EventListener))

Implementations: javax.swing.text.JTextComponent.AccessibleJTextComponent

Passed To: javax.swing.text.AbstractDocument.{addDocumentListener(), removeDocumentListener()}, javax.swing.text.DefaultStyledDocument.{addDocumentListener(), removeDocumentListener()}, javax.swing.text.Document.{addDocumentListener(), removeDocumentListener()}

EventListenerListJava 1.2
javax.swing.eventserializable

This utility class is used by many Swing classes to maintain lists of event listeners. An EventListenerList maintains a list of event listener objects, possibly of several different types. In order to allow the type of each listener to be determined efficiently, EventListenerList also maintains the java.lang.Class object for each EventListener.

The add() and remove() methods add and remove an event listener and its Class object to and from the list. When a component needs to send an event to all registered listeners of a given type, it calls getListenerList(). This method returns an array of objects, where the elements of this array are grouped in pairs. Each even-numbered element is a Class object that specifies the type of the event listener stored in the following odd-numbered element. Thus, you can quickly loop through the list of event listeners, comparing Class objects to find any registered listeners of the desired type. Objects that make use of EventListenerList must be careful not to modify the contents of the array returned by getListenerList().

public class EventListenerList implements Serializable {
// Public Constructors
public EventListenerList ();
// Property Accessor Methods (by property name)
public int getListenerCount (); default:0
public int getListenerCount (Class t);
public Object[ ] getListenerList ();
// Public Instance Methods
public void add (Class t, java.util.EventListener l); synchronized
public void remove (Class t, java.util.EventListener l); synchronized
// Public Methods Overriding Object
public String toString ();
// Protected Instance Fields
protected transient Object[ ] listenerList ;
}

Hierarchy: Object-->EventListenerList(Serializable)

Type Of: Too many fields to list.

HyperlinkEventJava 1.2
javax.swing.eventserializable event

An event of this type is generated by JEditorPane when the user moves the mouse over, clicks on, or moves the mouse off a hypertext link. getURL() returns the URL of the hyperlink. getEventType() returns an object constant indicating what was done to the hyperlink. The inherited getSource() method returns the JEditorPane that contains the hyperlink.

public class HyperlinkEvent extends java.util.EventObject {
// Public Constructors
public HyperlinkEvent (Object source, HyperlinkEvent.EventType type, java.net.URL u);
public HyperlinkEvent (Object source, HyperlinkEvent.EventType type, java.net.URL u, String desc);
// Inner Classes
;
// Public Instance Methods
public String getDescription ();
public HyperlinkEvent.EventType getEventType ();
public java.net.URL getURL ();
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->HyperlinkEvent

Subclasses: javax.swing.text.html.HTMLFrameHyperlinkEvent

Passed To: JEditorPane.fireHyperlinkUpdate(), HyperlinkListener.hyperlinkUpdate()

HyperlinkEvent.EventTypeJava 1.2
javax.swing.event

This class defines three type-safe object constants that are used to specify the type of a HyperlinkEvent.

public static final class HyperlinkEvent.EventType {
// No Constructor
// Public Constants
public static final HyperlinkEvent.EventType ACTIVATED ;
public static final HyperlinkEvent.EventType ENTERED ;
public static final HyperlinkEvent.EventType EXITED ;
// Public Methods Overriding Object
public String toString ();
}

Passed To: HyperlinkEvent.HyperlinkEvent(), javax.swing.text.html.HTMLFrameHyperlinkEvent.HTMLFrameHyperlinkEvent()

Returned By: HyperlinkEvent.getEventType()

Type Of: HyperlinkEvent.EventType.{ACTIVATED, ENTERED, EXITED}

HyperlinkListenerJava 1.2
javax.swing.eventevent listener

This interface defines the method that an object must implement in order to register for notifications about hyperlink activity in a JEditorPane component.

public abstract interface HyperlinkListener extends java.util.EventListener {
// Public Instance Methods
public abstract void hyperlinkUpdate (HyperlinkEvent e);
}

Hierarchy: (HyperlinkListener(java.util.EventListener))

Passed To: JEditorPane.{addHyperlinkListener(), removeHyperlinkListener()}

InternalFrameAdapterJava 1.2
javax.swing.eventevent adapter

This class is an empty implementation of InternalFrameListener. It is usually easier to extend this class than it is to implement InternalFrameListener from scratch.

public abstract class InternalFrameAdapter implements InternalFrameListener {
// Public Constructors
public InternalFrameAdapter ();
// Methods Implementing InternalFrameListener
public void internalFrameActivated (InternalFrameEvent e); empty
public void internalFrameClosed (InternalFrameEvent e); empty
public void internalFrameClosing (InternalFrameEvent e); empty
public void internalFrameDeactivated (InternalFrameEvent e); empty
public void internalFrameDeiconified (InternalFrameEvent e); empty
public void internalFrameIconified (InternalFrameEvent e); empty
public void internalFrameOpened (InternalFrameEvent e); empty
}

Hierarchy: Object-->InternalFrameAdapter(InternalFrameListener(java.util.EventListener))

InternalFrameEventJava 1.2
javax.swing.eventserializable event

Events of this type are generated when a JInternalFrame component changes state. An InternalFrameEvent is very similar to the java.awt.event.WindowEvent generated when a native window (such as a JFrame or JDialog) changes state. The inherited getSource() method returns the JInternalFrame object that generated the event. The inherited getID() method returns the type of the event; this return value is one of the constants defined by this class. The meanings of these constants are mostly straightforward. Note the distinction between INTERNAL_FRAME_CLOSING and INTERNAL_FRAME_CLOSED, however. The first type of event is generated when the user requests that the JInternalFrame be closed. The program may respond by hiding or destroying the window (it is poor style to ignore this type of event). The second type of event is generated only after the internal frame is actually hidden or destroyed.

public class InternalFrameEvent extends java.awt.AWTEvent {
// Public Constructors
public InternalFrameEvent (JInternalFrame source, int id);
// Public Constants
public static final int INTERNAL_FRAME_ACTIVATED ; =25554
public static final int INTERNAL_FRAME_CLOSED ; =25551
public static final int INTERNAL_FRAME_CLOSING ; =25550
public static final int INTERNAL_FRAME_DEACTIVATED ; =25555
public static final int INTERNAL_FRAME_DEICONIFIED ; =25553
public static final int INTERNAL_FRAME_FIRST ; =25549
public static final int INTERNAL_FRAME_ICONIFIED ; =25552
public static final int INTERNAL_FRAME_LAST ; =25555
public static final int INTERNAL_FRAME_OPENED ; =25549
// Public Methods Overriding AWTEvent
public String paramString ();
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->java.awt.AWTEvent-->InternalFrameEvent

Passed To: InternalFrameAdapter.{internalFrameActivated(), internalFrameClosed(), internalFrameClosing(), internalFrameDeactivated(), internalFrameDeiconified(), internalFrameIconified(), internalFrameOpened()}, InternalFrameListener.{internalFrameActivated(), internalFrameClosed(), internalFrameClosing(), internalFrameDeactivated(), internalFrameDeiconified(), internalFrameIconified(), internalFrameOpened()}

InternalFrameListenerJava 1.2
javax.swing.eventevent listener

This class defines the methods that an object must implement to receive notifications about state changes in a JInternalFrame. See InternalFrameEvent for a discussion of the difference between internalFrameClosed() and internalFrameClosing(). It is usually easier to subclass InternalFrameAdapter than to implement this interface from scratch.

public abstract interface InternalFrameListener extends java.util.EventListener {
// Public Instance Methods
public abstract void internalFrameActivated (InternalFrameEvent e);
public abstract void internalFrameClosed (InternalFrameEvent e);
public abstract void internalFrameClosing (InternalFrameEvent e);
public abstract void internalFrameDeactivated (InternalFrameEvent e);
public abstract void internalFrameDeiconified (InternalFrameEvent e);
public abstract void internalFrameIconified (InternalFrameEvent e);
public abstract void internalFrameOpened (InternalFrameEvent e);
}

Hierarchy: (InternalFrameListener(java.util.EventListener))

Implementations: InternalFrameAdapter

Passed To: JInternalFrame.{addInternalFrameListener(), removeInternalFrameListener()}

ListDataEventJava 1.2
javax.swing.eventserializable event

An event of this type is generated by a javax.swing.ListModel when the contents of the model changes. getType() returns one of the three constants defined by the class, to indicate the type of change that occurred. The inherited getSource() method returns the ListModel object that changed. getIndex0() and getIndex1() return the end points of the modified interval.

public class ListDataEvent extends java.util.EventObject {
// Public Constructors
public ListDataEvent (Object source, int type, int index0, int index1);
// Public Constants
public static final int CONTENTS_CHANGED ; =0
public static final int INTERVAL_ADDED ; =1
public static final int INTERVAL_REMOVED ; =2
// Public Instance Methods
public int getIndex0 ();
public int getIndex1 ();
public int getType ();
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->ListDataEvent

Passed To: JComboBox.{contentsChanged(), intervalAdded(), intervalRemoved()}, JList.AccessibleJList.{contentsChanged(), intervalAdded(), intervalRemoved()}, ListDataListener.{contentsChanged(), intervalAdded(), intervalRemoved()}

ListDataListenerJava 1.2
javax.swing.eventevent listener

This interface defines the methods that must be implemented by an object to receive notifications of changes to the contents of a javax.swing.ListModel.

public abstract interface ListDataListener extends java.util.EventListener {
// Public Instance Methods
public abstract void contentsChanged (ListDataEvent e);
public abstract void intervalAdded (ListDataEvent e);
public abstract void intervalRemoved (ListDataEvent e);
}

Hierarchy: (ListDataListener(java.util.EventListener))

Implementations: JComboBox, JList.AccessibleJList

Passed To: AbstractListModel.{addListDataListener(), removeListDataListener()}, ListModel.{addListDataListener(), removeListDataListener()}

ListSelectionEventJava 1.2
javax.swing.eventserializable event

An event of this type is generated by a JList component or its underlying ListSelectionModel object to indicate a change in the current list selection. getFirstIndex() and getLastIndex() return the first and last elements in the list that may have had their selection state changed. The ListSelectionEvent does not contain the new selection state; you must query the JList or ListSelectionModel for that information. (Use the inherited getSource() method to obtain the source of the event). getValueIsAdjusting() returns true if the event is one in a series of rapid-fire events, such as those that are generated when the user drags the mouse through a JList. Some programs may choose to ignore these rapid-fire events and wait for an event for which getValueIsAdjusting() returns false.

public class ListSelectionEvent extends java.util.EventObject {
// Public Constructors
public ListSelectionEvent (Object source, int firstIndex, int lastIndex, boolean isAdjusting);
// Public Instance Methods
public int getFirstIndex ();
public int getLastIndex ();
public boolean getValueIsAdjusting ();
// Public Methods Overriding EventObject
public String toString ();
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->ListSelectionEvent

Passed To: JList.AccessibleJList.valueChanged(), JTable.{columnSelectionChanged(), valueChanged()}, JTable.AccessibleJTable.{columnSelectionChanged(), valueChanged()}, ListSelectionListener.valueChanged(), TableColumnModelListener.columnSelectionChanged(), javax.swing.table.DefaultTableColumnModel.{fireColumnSelectionChanged(), valueChanged()}, javax.swing.table.JTableHeader.columnSelectionChanged()

ListSelectionListenerJava 1.2
javax.swing.eventevent listener

This interface defines the method that an object must implement in order to receive notifications of changes in the selection state of a JList or ListSelectionModel.

public abstract interface ListSelectionListener extends java.util.EventListener {
// Public Instance Methods
public abstract void valueChanged (ListSelectionEvent e);
}

Hierarchy: (ListSelectionListener(java.util.EventListener))

Implementations: JList.AccessibleJList, JTable, JTable.AccessibleJTable, javax.swing.table.DefaultTableColumnModel

Passed To: DefaultListSelectionModel.{addListSelectionListener(), removeListSelectionListener()}, JList.{addListSelectionListener(), removeListSelectionListener()}, ListSelectionModel.{addListSelectionListener(), removeListSelectionListener()}

MenuDragMouseEventJava 1.2
javax.swing.eventserializable event

JMenuItem sends events of this type to registered MenuDragMouseListener objects to signal that the mouse has entered or exited the menu item, that it is moving over the menu item, or that the user has released the mouse button over the menu item.

public class MenuDragMouseEvent extends java.awt.event.MouseEvent {
// Public Constructors
public MenuDragMouseEvent (Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger, MenuElement[ ] p, MenuSelectionManager m);
// Public Instance Methods
public MenuSelectionManager getMenuSelectionManager ();
public MenuElement[ ] getPath ();
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->java.awt.AWTEvent-->java.awt.event.ComponentEvent-->java.awt.event.InputEvent-->java.awt.event.MouseEvent-->MenuDragMouseEvent

Passed To: JMenuItem.{fireMenuDragMouseDragged(), fireMenuDragMouseEntered(), fireMenuDragMouseExited(), fireMenuDragMouseReleased(), processMenuDragMouseEvent()}, MenuDragMouseListener.{menuDragMouseDragged(), menuDragMouseEntered(), menuDragMouseExited(), menuDragMouseReleased()}

MenuDragMouseListenerJava 1.2
javax.swing.eventevent listener

This interface defines the methods that JMenuItem invokes on registered objects when the user drags the mouse into, over, or out of the menu item or releases the mouse button over the item.

public abstract interface MenuDragMouseListener extends java.util.EventListener {
// Public Instance Methods
public abstract void menuDragMouseDragged (MenuDragMouseEvent e);
public abstract void menuDragMouseEntered (MenuDragMouseEvent e);
public abstract void menuDragMouseExited (MenuDragMouseEvent e);
public abstract void menuDragMouseReleased (MenuDragMouseEvent e);
}

Hierarchy: (MenuDragMouseListener(java.util.EventListener))

Passed To: JMenuItem.{addMenuDragMouseListener(), removeMenuDragMouseListener()}

MenuEventJava 1.2
javax.swing.eventserializable event

Events of this type are generated by a JMenu component to indicate that the menu button has been selected or deselected. (When the menu attached to that button actually pops up or down, the JPopupMenu component generates a PopupMenuEvent.) The inherited getSource() method returns the JMenu object that generated the event. The type of the MenuEvent depends on which MenuListener method it is passed to.

public class MenuEvent extends java.util.EventObject {
// Public Constructors
public MenuEvent (Object source);
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->MenuEvent

Passed To: MenuListener.{menuCanceled(), menuDeselected(), menuSelected()}

MenuKeyEventJava 1.2
javax.swing.eventserializable event

JMenuItem sends events of this type to registered MenuKeyListener objects when the user types a key over the menu item.

public class MenuKeyEvent extends java.awt.event.KeyEvent {
// Public Constructors
public MenuKeyEvent (Component source, int id, long when, int modifiers, int keyCode, char keyChar, MenuElement[ ] p, MenuSelectionManager m);
// Public Instance Methods
public MenuSelectionManager getMenuSelectionManager ();
public MenuElement[ ] getPath ();
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->java.awt.AWTEvent-->java.awt.event.ComponentEvent-->java.awt.event.InputEvent-->java.awt.event.KeyEvent-->MenuKeyEvent

Passed To: JMenuItem.{fireMenuKeyPressed(), fireMenuKeyReleased(), fireMenuKeyTyped(), processMenuKeyEvent()}, MenuKeyListener.{menuKeyPressed(), menuKeyReleased(), menuKeyTyped()}

MenuKeyListenerJava 1.2
javax.swing.eventevent listener

This interface defines the method that a JMenuItem invokes on registered listeners when the user types a key in the menu item.

public abstract interface MenuKeyListener extends java.util.EventListener {
// Public Instance Methods
public abstract void menuKeyPressed (MenuKeyEvent e);
public abstract void menuKeyReleased (MenuKeyEvent e);
public abstract void menuKeyTyped (MenuKeyEvent e);
}

Hierarchy: (MenuKeyListener(java.util.EventListener))

Passed To: JMenuItem.{addMenuKeyListener(), removeMenuKeyListener()}

MenuListenerJava 1.2
javax.swing.eventevent listener

This interface defines the methods that an object must implement in order to be notified when a JMenu button is selected or deselected or when a menu selection is canceled.

public abstract interface MenuListener extends java.util.EventListener {
// Public Instance Methods
public abstract void menuCanceled (MenuEvent e);
public abstract void menuDeselected (MenuEvent e);
public abstract void menuSelected (MenuEvent e);
}

Hierarchy: (MenuListener(java.util.EventListener))

Passed To: JMenu.{addMenuListener(), removeMenuListener()}

MouseInputAdapterJava 1.2
javax.swing.eventevent adapter

This class is an empty implementation of MouseInputListener. It often is easier to subclass this class, overriding only the methods you are interested in, than it is to implement all the methods of java.awt.event.MouseMotionListener from scratch.

public abstract class MouseInputAdapter implements MouseInputListener {
// Public Constructors
public MouseInputAdapter ();
// Methods Implementing MouseListener
public void mouseClicked (java.awt.event.MouseEvent e); empty
public void mouseEntered (java.awt.event.MouseEvent e); empty
public void mouseExited (java.awt.event.MouseEvent e); empty
public void mousePressed (java.awt.event.MouseEvent e); empty
public void mouseReleased (java.awt.event.MouseEvent e); empty
// Methods Implementing MouseMotionListener
public void mouseDragged (java.awt.event.MouseEvent e); empty
public void mouseMoved (java.awt.event.MouseEvent e); empty
}

Hierarchy: Object-->MouseInputAdapter(MouseInputListener(java.awt.event.MouseListener(java.util.EventListener),java.awt.event.MouseMotionListener(java.util.EventListener)))

MouseInputListenerJava 1.2
javax.swing.eventevent listener

MouseInputListener combines into a single interface the methods of the closely related MouseListener and MouseMotionListener interfaces of the java.awt.event package. This interface is a simple utility that makes it easier to implement both MouseEvent listener interfaces at once.

public abstract interface MouseInputListener extends java.awt.event.MouseListener, java.awt.event.MouseMotionListener {
}

Hierarchy: (MouseInputListener(java.awt.event.MouseListener(java.util.EventListener),java.awt.event.MouseMotionListener(java.util.EventListener)))

Implementations: MouseInputAdapter

PopupMenuEventJava 1.2
javax.swing.eventserializable event

An event of this type is generated just before a JPopupMenu is popped up or popped down or when a JPopupMenu is canceled (i.e., when it is popped down without the user making a selection). The inherited getSource() method returns the JPopupMenu, but PopupMenuEvent contains no other state. The type of the event is determined by the PopupMenuListener method to which it is passed.

public class PopupMenuEvent extends java.util.EventObject {
// Public Constructors
public PopupMenuEvent (Object source);
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->PopupMenuEvent

Passed To: PopupMenuListener.{popupMenuCanceled(), popupMenuWillBecomeInvisible(), popupMenuWillBecomeVisible()}

PopupMenuListenerJava 1.2
javax.swing.eventevent listener

This interface defines the methods that an object must implement to receive notifications that a JPopupMenu is about to pop up or pop down or that a JPopupMenu was canceled without a user selection.

public abstract interface PopupMenuListener extends java.util.EventListener {
// Public Instance Methods
public abstract void popupMenuCanceled (PopupMenuEvent e);
public abstract void popupMenuWillBecomeInvisible (PopupMenuEvent e);
public abstract void popupMenuWillBecomeVisible (PopupMenuEvent e);
}

Hierarchy: (PopupMenuListener(java.util.EventListener))

Passed To: JPopupMenu.{addPopupMenuListener(), removePopupMenuListener()}

SwingPropertyChangeSupportJava 1.2
javax.swing.eventserializable

This utility class is useful when you are defining a Swing component that has bound properties and must fire java.beans.PropertyChangeEvent events when the value of various properties change. This class is a subclass of java.beans.PropertyChangeSupport and provides the same features as that class. This Swing-specific version is somewhat more memory efficient than the JavaBeans version and does not use synchronized methods.

public final class SwingPropertyChangeSupport extends java.beans.PropertyChangeSupport {
// Public Constructors
public SwingPropertyChangeSupport (Object sourceBean);
// Event Registration Methods (by event name)
public void addPropertyChangeListener (java.beans.PropertyChangeListener listener); Overrides:PropertyChangeSupport synchronized
public void removePropertyChangeListener (java.beans.PropertyChangeListener listener); Overrides:PropertyChangeSupport synchronized
// Public Methods Overriding PropertyChangeSupport
public void addPropertyChangeListener (String propertyName, java.beans.PropertyChangeListener listener); synchronized
public void firePropertyChange (java.beans.PropertyChangeEvent evt);
public void firePropertyChange (String propertyName, Object oldValue, Object newValue);
public boolean hasListeners (String propertyName); synchronized
public void removePropertyChangeListener (String propertyName, java.beans.PropertyChangeListener listener); synchronized
}

Hierarchy: Object-->java.beans.PropertyChangeSupport(Serializable)-->SwingPropertyChangeSupport

Type Of: AbstractAction.changeSupport, javax.swing.tree.DefaultTreeSelectionModel.changeSupport

TableColumnModelEventJava 1.2
javax.swing.eventserializable event

An event of this type is generated when a column is added, deleted, or moved from a javax.swing.table.TableColumnModel. The inherited getSource() method returns the TableColumnModel object that was changed. When a column is added, getToIndex() specifies the index of the column. When a column is removed, getFromIndex() specifies the index that it used to occupy. When a column is moved, getFromIndex() returns the column's old position and getToIndex() returns the column's new position.

public class TableColumnModelEvent extends java.util.EventObject {
// Public Constructors
public TableColumnModelEvent (javax.swing.table.TableColumnModel source, int from, int to);
// Public Instance Methods
public int getFromIndex ();
public int getToIndex ();
// Protected Instance Fields
protected int fromIndex ;
protected int toIndex ;
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->TableColumnModelEvent

Passed To: JTable.{columnAdded(), columnMoved(), columnRemoved()}, JTable.AccessibleJTable.{columnAdded(), columnMoved(), columnRemoved()}, TableColumnModelListener.{columnAdded(), columnMoved(), columnRemoved()}, javax.swing.table.DefaultTableColumnModel.{fireColumnAdded(), fireColumnMoved(), fireColumnRemoved()}, javax.swing.table.JTableHeader.{columnAdded(), columnMoved(), columnRemoved()}

TableColumnModelListenerJava 1.2
javax.swing.eventevent listener

This interface defines the methods that an object must implement to receive notifications of changes in a javax.swing.table.TableColumnModel. Note that unlike most event listeners, the methods of this object are passed different types of event objects.

public abstract interface TableColumnModelListener extends java.util.EventListener {
// Public Instance Methods
public abstract void columnAdded (TableColumnModelEvent e);
public abstract void columnMarginChanged (ChangeEvent e);
public abstract void columnMoved (TableColumnModelEvent e);
public abstract void columnRemoved (TableColumnModelEvent e);
public abstract void columnSelectionChanged (ListSelectionEvent e);
}

Hierarchy: (TableColumnModelListener(java.util.EventListener))

Implementations: JTable, JTable.AccessibleJTable, javax.swing.table.JTableHeader

Passed To: javax.swing.table.DefaultTableColumnModel.{addColumnModelListener(), removeColumnModelListener()}, javax.swing.table.TableColumnModel.{addColumnModelListener(), removeColumnModelListener()}

TableModelEventJava 1.2
javax.swing.eventserializable event

An event of this type is generated by a javax.swing.table.TableModel when the data it contains changes. getColumn() indicates the column that changed; it may return the constant ALL_COLUMNS. getFirstRow() and getLastRow() get the range of modified rows. If either returns the constant HEADER_ROW, that indicates that the entire structure of the table has changed along with the table data. getType() specifies the type of the change; it returns one of the constants DELETE, INSERT, or UPDATE. The inherited getSource() method returns the modified TableModel object.

public class TableModelEvent extends java.util.EventObject {
// Public Constructors
public TableModelEvent (javax.swing.table.TableModel source);
public TableModelEvent (javax.swing.table.TableModel source, int row);
public TableModelEvent (javax.swing.table.TableModel source, int firstRow, int lastRow);
public TableModelEvent (javax.swing.table.TableModel source, int firstRow, int lastRow, int column);
public TableModelEvent (javax.swing.table.TableModel source, int firstRow, int lastRow, int column, int type);
// Public Constants
public static final int ALL_COLUMNS ; =-1
public static final int DELETE ; =-1
public static final int HEADER_ROW ; =-1
public static final int INSERT ; =1
public static final int UPDATE ; =0
// Property Accessor Methods (by property name)
public int getColumn ();
public int getFirstRow ();
public int getLastRow ();
public int getType ();
// Protected Instance Fields
protected int column ;
protected int firstRow ;
protected int lastRow ;
protected int type ;
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->TableModelEvent

Passed To: JTable.tableChanged(), JTable.AccessibleJTable.{tableChanged(), tableRowsDeleted(), tableRowsInserted()}, TableModelListener.tableChanged(), javax.swing.table.AbstractTableModel.fireTableChanged(), javax.swing.table.DefaultTableModel.{newDataAvailable(), newRowsAdded(), rowsRemoved()}

TableModelListenerJava 1.2
javax.swing.eventevent listener

This interface defines the method that an object must implement to receive notifications about changes to the state of a javax.swing.table.TableModel.

public abstract interface TableModelListener extends java.util.EventListener {
// Public Instance Methods
public abstract void tableChanged (TableModelEvent e);
}

Hierarchy: (TableModelListener(java.util.EventListener))

Implementations: JTable, JTable.AccessibleJTable

Passed To: javax.swing.table.AbstractTableModel.{addTableModelListener(), removeTableModelListener()}, javax.swing.table.TableModel.{addTableModelListener(), removeTableModelListener()}

TreeExpansionEventJava 1.2
javax.swing.eventserializable event

An event of this type is generated by a JTree component when a node in the tree is expanded or collapsed. The inherited getSource() method returns the JTree component, and getPath() returns a TreePath that specifies which node was expanded or collapsed.

public class TreeExpansionEvent extends java.util.EventObject {
// Public Constructors
public TreeExpansionEvent (Object source, javax.swing.tree.TreePath path);
// Public Instance Methods
public javax.swing.tree.TreePath getPath ();
// Protected Instance Fields
protected javax.swing.tree.TreePath path ;
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->TreeExpansionEvent

Passed To: JTree.AccessibleJTree.{treeCollapsed(), treeExpanded()}, TreeExpansionListener.{treeCollapsed(), treeExpanded()}, TreeWillExpandListener.{treeWillCollapse(), treeWillExpand()}, javax.swing.tree.ExpandVetoException.ExpandVetoException()

Type Of: javax.swing.tree.ExpandVetoException.event

TreeExpansionListenerJava 1.2
javax.swing.eventevent listener

This interface defines the methods that an object must implement to be notified when a JTree component expands or collapses a node.

public abstract interface TreeExpansionListener extends java.util.EventListener {
// Public Instance Methods
public abstract void treeCollapsed (TreeExpansionEvent event);
public abstract void treeExpanded (TreeExpansionEvent event);
}

Hierarchy: (TreeExpansionListener(java.util.EventListener))

Implementations: JTree.AccessibleJTree

Passed To: JTree.{addTreeExpansionListener(), removeTreeExpansionListener()}

TreeModelEventJava 1.2
javax.swing.eventserializable event

An event of this type is generated when the contents of a java.awt.event.tree.TreeModel change. The inherited getSource() method returns the TreeModel object that was changed. getPath() and getTreePath() specify the path to the parent of the changed nodes. getChildIndices() returns an array of integers that specifies which children of that parent node have changed. Alternatively, getChildren() returns the modified children directly. TreeModelEvent does not directly indicate what type of change has occurred; that is determined by the TreeModelListener method to which the TreeModelEvent is passed.

public class TreeModelEvent extends java.util.EventObject {
// Public Constructors
public TreeModelEvent (Object source, Object[ ] path);
public TreeModelEvent (Object source, javax.swing.tree.TreePath path);
public TreeModelEvent (Object source, javax.swing.tree.TreePath path, int[ ] childIndices, Object[ ] children);
public TreeModelEvent (Object source, Object[ ] path, int[ ] childIndices, Object[ ] children);
// Property Accessor Methods (by property name)
public int[ ] getChildIndices ();
public Object[ ] getChildren ();
public Object[ ] getPath ();
public javax.swing.tree.TreePath getTreePath ();
// Public Methods Overriding EventObject
public String toString ();
// Protected Instance Fields
protected int[ ] childIndices ;
protected Object[ ] children ;
protected javax.swing.tree.TreePath path ;
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->TreeModelEvent

Passed To: Too many methods to list.

TreeModelListenerJava 1.2
javax.swing.eventevent listener

This interface defines the methods that an object must implement to receive notifications of changes to a javax.swing.tree.TreeModel.

public abstract interface TreeModelListener extends java.util.EventListener {
// Public Instance Methods
public abstract void treeNodesChanged (TreeModelEvent e);
public abstract void treeNodesInserted (TreeModelEvent e);
public abstract void treeNodesRemoved (TreeModelEvent e);
public abstract void treeStructureChanged (TreeModelEvent e);
}

Hierarchy: (TreeModelListener(java.util.EventListener))

Implementations: JTree.AccessibleJTree, JTree.TreeModelHandler

Passed To: javax.swing.tree.DefaultTreeModel.{addTreeModelListener(), removeTreeModelListener()}, javax.swing.tree.TreeModel.{addTreeModelListener(), removeTreeModelListener()}

Returned By: JTree.createTreeModelListener()

Type Of: JTree.treeModelListener

TreeSelectionEventJava 1.2
javax.swing.eventserializable event

An event of this type is generated by a javax.swing.tree.TreeSelectionModel or by the JTree component that uses that model when the selection state of the tree changes. getPaths() returns the array of javax.swing.tree.TreePath objects that were added to or removed from the selection. getPath() returns the first element of this array. The one-argument version of isAddedPath() tests whether a specified TreePath (it must be one of the ones returned by getPaths()) was added to the selection (true) or removed from it (false). The no-argument version of this method tests whether the value returned by getPath() was selected or deselected.

public class TreeSelectionEvent extends java.util.EventObject {
// Public Constructors
public TreeSelectionEvent (Object source, javax.swing.tree.TreePath[ ] paths, boolean[ ] areNew, javax.swing.tree.TreePath oldLeadSelectionPath, javax.swing.tree.TreePath newLeadSelectionPath);
public TreeSelectionEvent (Object source, javax.swing.tree.TreePath path, boolean isNew, javax.swing.tree.TreePath oldLeadSelectionPath, javax.swing.tree.TreePath newLeadSelectionPath);
// Property Accessor Methods (by property name)
public boolean isAddedPath ();
public boolean isAddedPath (javax.swing.tree.TreePath path);
public javax.swing.tree.TreePath getNewLeadSelectionPath ();
public javax.swing.tree.TreePath getOldLeadSelectionPath ();
public javax.swing.tree.TreePath getPath ();
public javax.swing.tree.TreePath[ ] getPaths ();
// Public Instance Methods
public Object cloneWithSource (Object newSource);
// Protected Instance Fields
protected boolean[ ] areNew ;
protected javax.swing.tree.TreePath newLeadSelectionPath ;
protected javax.swing.tree.TreePath oldLeadSelectionPath ;
protected javax.swing.tree.TreePath[ ] paths ;
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->TreeSelectionEvent

Passed To: JTree.fireValueChanged(), JTree.AccessibleJTree.valueChanged(), JTree.TreeSelectionRedirector.valueChanged(), TreeSelectionListener.valueChanged(), javax.swing.tree.DefaultTreeCellEditor.valueChanged(), javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged()

TreeSelectionListenerJava 1.2
javax.swing.eventevent listener

This interface defines the method that an object must implement to receive notifications about changes to the selection state of a javax.swing.tree.TreeSelectionModel object or JTree component.

public abstract interface TreeSelectionListener extends java.util.EventListener {
// Public Instance Methods
public abstract void valueChanged (TreeSelectionEvent e);
}

Hierarchy: (TreeSelectionListener(java.util.EventListener))

Implementations: JTree.AccessibleJTree, JTree.TreeSelectionRedirector, javax.swing.tree.DefaultTreeCellEditor

Passed To: JTree.{addTreeSelectionListener(), removeTreeSelectionListener()}, javax.swing.tree.DefaultTreeSelectionModel.{addTreeSelectionListener(), removeTreeSelectionListener()}, javax.swing.tree.TreeSelectionModel.{addTreeSelectionListener(), removeTreeSelectionListener()}

TreeWillExpandListenerJava 1.2
javax.swing.eventevent listener

This interface defines the methods that JTree invokes on registered listeners immediately before it expands or collapses a node. Do not confuse this interface with TreeExpansionListener, which is notified immediately after a node is expanded or collapsed. Both listeners share the same TreeExpansionEvent event type, however. Note that the methods of this interface can throw an ExpandVetoException to veto the proposed expansion or collapse of the node.

public abstract interface TreeWillExpandListener extends java.util.EventListener {
// Public Instance Methods
public abstract void treeWillCollapse (TreeExpansionEvent event) throws javax.swing.tree.ExpandVetoException;
public abstract void treeWillExpand (TreeExpansionEvent event) throws javax.swing.tree.ExpandVetoException;
}

Hierarchy: (TreeWillExpandListener(java.util.EventListener))

Passed To: JTree.{addTreeWillExpandListener(), removeTreeWillExpandListener()}

UndoableEditEventJava 1.2
javax.swing.eventserializable event

An event of this type is generated by a javax.swing.text.Document when an undoable edit has occurred. The inherited getSource() method returns the Document object on which the edit occurred, and getEdit() returns a description of the edit itself.

public class UndoableEditEvent extends java.util.EventObject {
// Public Constructors
public UndoableEditEvent (Object source, javax.swing.undo.UndoableEdit edit);
// Public Instance Methods
public javax.swing.undo.UndoableEdit getEdit ();
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->UndoableEditEvent

Passed To: UndoableEditListener.undoableEditHappened(), javax.swing.text.AbstractDocument.fireUndoableEditUpdate(), javax.swing.text.html.HTMLDocument.fireUndoableEditUpdate(), javax.swing.undo.UndoManager.undoableEditHappened()

UndoableEditListenerJava 1.2
javax.swing.eventevent listener

This interface defines the method that an object must implement in order to receive notifications when an undoable edit occurs in a javax.swing.text.Document.

public abstract interface UndoableEditListener extends java.util.EventListener {
// Public Instance Methods
public abstract void undoableEditHappened (UndoableEditEvent e);
}

Hierarchy: (UndoableEditListener(java.util.EventListener))

Implementations: javax.swing.undo.UndoManager

Passed To: javax.swing.text.AbstractDocument.{addUndoableEditListener(), removeUndoableEditListener()}, javax.swing.text.Document.{addUndoableEditListener(), removeUndoableEditListener()}, javax.swing.undo.UndoableEditSupport.{addUndoableEditListener(), removeUndoableEditListener()}



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.

This HTML Help has been published using the chm2web software.