hep.wired.util
Class SwingEventMulticaster

java.lang.Object
  extended by java.awt.AWTEventMulticaster
      extended by hep.wired.util.SwingEventMulticaster
All Implemented Interfaces:
ActionListener, AdjustmentListener, ComponentListener, ContainerListener, FocusListener, HierarchyBoundsListener, HierarchyListener, InputMethodListener, ItemListener, KeyListener, MouseListener, MouseMotionListener, MouseWheelListener, TextListener, WindowFocusListener, WindowListener, WindowStateListener, EventListener, AncestorListener, CaretListener, CellEditorListener, ChangeListener, DocumentListener, HyperlinkListener, InternalFrameListener, ListDataListener, ListSelectionListener, MenuDragMouseListener, MenuKeyListener, MenuListener, PopupMenuListener, TableColumnModelListener, TableModelListener, TreeExpansionListener, TreeModelListener, TreeSelectionListener, TreeWillExpandListener, UndoableEditListener

public class SwingEventMulticaster
extends AWTEventMulticaster
implements AncestorListener, CaretListener, CellEditorListener, ChangeListener, DocumentListener, HyperlinkListener, InternalFrameListener, ListDataListener, ListSelectionListener, MenuDragMouseListener, MenuKeyListener, MenuListener, PopupMenuListener, TableColumnModelListener, TableModelListener, TreeExpansionListener, TreeModelListener, TreeSelectionListener, TreeWillExpandListener, UndoableEditListener

A class which implements efficient and thread-safe multi-cast event dispatching for the SWING events defined in the javax.swing.event package. This class will manage an immutable structure consisting of a chain of event listeners and will dispatch events to those listeners. Because the structure is immutable, it is safe to use this API to add/remove listeners during the process of an event dispatch operation. However, event listeners added during the process of an event dispatch operation will not be notified of the event currently being dispatched. An example of how this class could be used to implement a new component which fires "action" events:


 public myComponent extends JComponent {
     ChangeListener changeListener = null;

     public synchronized void addChangeListener(ChangeListener l) {
         changeListener = SwingEventMulticaster.add(changeListener, l);
     }
     
     public synchronized void removeChangeListener(ChangeListener l) {
         changeListener = SwingEventMulticaster.remove(changeListener, l);
     }
     
     public void processEvent(SwingEvent e) {
         // when event occurs which causes "action" semantic
         ChangeListener listener = changeListener;
         if (listener != null) {
             listener.stateChanged(new ChangeEvent());
         }
     }
 }
 
original source http://www.fawcette.com/archives/premier/mgznarch/javapro/2001/01jan01/vc0101/vc0101.asp

Version:
$Id: SwingEventMulticaster.java 8598 2006-08-14 20:38:02Z duns $
Author:
Mark Donszelmann

Field Summary
 
Fields inherited from class java.awt.AWTEventMulticaster
a, b
 
Constructor Summary
protected SwingEventMulticaster(EventListener a, EventListener b)
           
 
Method Summary
static AncestorListener add(AncestorListener a, AncestorListener b)
           
static CaretListener add(CaretListener a, CaretListener b)
           
static CellEditorListener add(CellEditorListener a, CellEditorListener b)
           
static ChangeListener add(ChangeListener a, ChangeListener b)
           
static DocumentListener add(DocumentListener a, DocumentListener b)
           
static HyperlinkListener add(HyperlinkListener a, HyperlinkListener b)
           
static InternalFrameListener add(InternalFrameListener a, InternalFrameListener b)
           
static ListDataListener add(ListDataListener a, ListDataListener b)
           
static ListSelectionListener add(ListSelectionListener a, ListSelectionListener b)
           
static MenuDragMouseListener add(MenuDragMouseListener a, MenuDragMouseListener b)
           
static MenuKeyListener add(MenuKeyListener a, MenuKeyListener b)
           
static MenuListener add(MenuListener a, MenuListener b)
           
static PopupMenuListener add(PopupMenuListener a, PopupMenuListener b)
           
static TableColumnModelListener add(TableColumnModelListener a, TableColumnModelListener b)
           
static TableModelListener add(TableModelListener a, TableModelListener b)
           
static TreeExpansionListener add(TreeExpansionListener a, TreeExpansionListener b)
           
static TreeModelListener add(TreeModelListener a, TreeModelListener b)
           
static TreeSelectionListener add(TreeSelectionListener a, TreeSelectionListener b)
           
static TreeWillExpandListener add(TreeWillExpandListener a, TreeWillExpandListener b)
           
static UndoableEditListener add(UndoableEditListener a, UndoableEditListener b)
           
protected static EventListener addInternal(EventListener a, EventListener b)
           
 void ancestorAdded(AncestorEvent event)
           
 void ancestorMoved(AncestorEvent event)
           
 void ancestorRemoved(AncestorEvent event)
           
 void caretUpdate(CaretEvent event)
           
 void changedUpdate(DocumentEvent event)
           
 void columnAdded(TableColumnModelEvent event)
           
 void columnMarginChanged(ChangeEvent event)
           
 void columnMoved(TableColumnModelEvent event)
           
 void columnRemoved(TableColumnModelEvent event)
           
 void columnSelectionChanged(ListSelectionEvent event)
           
 void contentsChanged(ListDataEvent event)
           
static void dumpList(EventListener l)
           
 void editingCanceled(ChangeEvent event)
           
 void editingStopped(ChangeEvent event)
           
 void hyperlinkUpdate(HyperlinkEvent event)
           
 void insertUpdate(DocumentEvent event)
           
 void internalFrameActivated(InternalFrameEvent event)
           
 void internalFrameClosed(InternalFrameEvent event)
           
 void internalFrameClosing(InternalFrameEvent event)
           
 void internalFrameDeactivated(InternalFrameEvent event)
           
 void internalFrameDeiconified(InternalFrameEvent event)
           
 void internalFrameIconified(InternalFrameEvent event)
           
 void internalFrameOpened(InternalFrameEvent event)
           
 void intervalAdded(ListDataEvent event)
           
 void intervalRemoved(ListDataEvent event)
           
 void menuCanceled(MenuEvent event)
           
 void menuDeselected(MenuEvent event)
           
 void menuDragMouseDragged(MenuDragMouseEvent event)
           
 void menuDragMouseEntered(MenuDragMouseEvent event)
           
 void menuDragMouseExited(MenuDragMouseEvent event)
           
 void menuDragMouseReleased(MenuDragMouseEvent event)
           
 void menuKeyPressed(MenuKeyEvent event)
           
 void menuKeyReleased(MenuKeyEvent event)
           
 void menuKeyTyped(MenuKeyEvent event)
           
 void menuSelected(MenuEvent event)
           
 void popupMenuCanceled(PopupMenuEvent event)
           
 void popupMenuWillBecomeInvisible(PopupMenuEvent event)
           
 void popupMenuWillBecomeVisible(PopupMenuEvent event)
           
static AncestorListener remove(AncestorListener l, AncestorListener oldl)
           
static CaretListener remove(CaretListener l, CaretListener oldl)
           
static CellEditorListener remove(CellEditorListener l, CellEditorListener oldl)
           
static ChangeListener remove(ChangeListener l, ChangeListener oldl)
           
static DocumentListener remove(DocumentListener l, DocumentListener oldl)
           
protected  EventListener remove(EventListener oldl)
          Removes a listener from this multicaster and returns the resulting multicast listener.
static HyperlinkListener remove(HyperlinkListener l, HyperlinkListener oldl)
           
static InternalFrameListener remove(InternalFrameListener l, InternalFrameListener oldl)
           
static ListDataListener remove(ListDataListener l, ListDataListener oldl)
           
static ListSelectionListener remove(ListSelectionListener l, ListSelectionListener oldl)
           
static MenuDragMouseListener remove(MenuDragMouseListener l, MenuDragMouseListener oldl)
           
static MenuKeyListener remove(MenuKeyListener l, MenuKeyListener oldl)
           
static MenuListener remove(MenuListener l, MenuListener oldl)
           
static PopupMenuListener remove(PopupMenuListener l, PopupMenuListener oldl)
           
static TableColumnModelListener remove(TableColumnModelListener l, TableColumnModelListener oldl)
           
static TableModelListener remove(TableModelListener l, TableModelListener oldl)
           
static TreeExpansionListener remove(TreeExpansionListener l, TreeExpansionListener oldl)
           
static TreeModelListener remove(TreeModelListener l, TreeModelListener oldl)
           
static TreeSelectionListener remove(TreeSelectionListener l, TreeSelectionListener oldl)
           
static TreeWillExpandListener remove(TreeWillExpandListener l, TreeWillExpandListener oldl)
           
static UndoableEditListener remove(UndoableEditListener l, UndoableEditListener oldl)
           
protected static EventListener removeInternal(EventListener l, EventListener oldl)
           
 void removeUpdate(DocumentEvent event)
           
 void stateChanged(ChangeEvent event)
           
 void tableChanged(TableModelEvent event)
           
 void treeCollapsed(TreeExpansionEvent event)
           
 void treeExpanded(TreeExpansionEvent event)
           
 void treeNodesChanged(TreeModelEvent event)
           
 void treeNodesInserted(TreeModelEvent event)
           
 void treeNodesRemoved(TreeModelEvent event)
           
 void treeStructureChanged(TreeModelEvent event)
           
 void treeWillCollapse(TreeExpansionEvent event)
           
 void treeWillExpand(TreeExpansionEvent event)
           
 void undoableEditHappened(UndoableEditEvent event)
           
 void valueChanged(ListSelectionEvent event)
           
 void valueChanged(TreeSelectionEvent event)
           
 
Methods inherited from class java.awt.AWTEventMulticaster
actionPerformed, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, adjustmentValueChanged, ancestorMoved, ancestorResized, caretPositionChanged, componentAdded, componentHidden, componentMoved, componentRemoved, componentResized, componentShown, focusGained, focusLost, getListeners, hierarchyChanged, inputMethodTextChanged, itemStateChanged, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, remove, save, saveInternal, textValueChanged, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowGainedFocus, windowIconified, windowLostFocus, windowOpened, windowStateChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingEventMulticaster

protected SwingEventMulticaster(EventListener a,
                                EventListener b)
Method Detail

remove

protected EventListener remove(EventListener oldl)
Removes a listener from this multicaster and returns the resulting multicast listener. Overridden to make sure the correct addInternal method is called (which creates a multicaster). MD

Overrides:
remove in class AWTEventMulticaster
Parameters:
oldl - the listener to be removed

dumpList

public static void dumpList(EventListener l)

ancestorAdded

public void ancestorAdded(AncestorEvent event)
Specified by:
ancestorAdded in interface AncestorListener

ancestorRemoved

public void ancestorRemoved(AncestorEvent event)
Specified by:
ancestorRemoved in interface AncestorListener

ancestorMoved

public void ancestorMoved(AncestorEvent event)
Specified by:
ancestorMoved in interface AncestorListener

add

public static AncestorListener add(AncestorListener a,
                                   AncestorListener b)

remove

public static AncestorListener remove(AncestorListener l,
                                      AncestorListener oldl)

caretUpdate

public void caretUpdate(CaretEvent event)
Specified by:
caretUpdate in interface CaretListener

add

public static CaretListener add(CaretListener a,
                                CaretListener b)

remove

public static CaretListener remove(CaretListener l,
                                   CaretListener oldl)

editingCanceled

public void editingCanceled(ChangeEvent event)
Specified by:
editingCanceled in interface CellEditorListener

editingStopped

public void editingStopped(ChangeEvent event)
Specified by:
editingStopped in interface CellEditorListener

add

public static CellEditorListener add(CellEditorListener a,
                                     CellEditorListener b)

remove

public static CellEditorListener remove(CellEditorListener l,
                                        CellEditorListener oldl)

stateChanged

public void stateChanged(ChangeEvent event)
Specified by:
stateChanged in interface ChangeListener

add

public static ChangeListener add(ChangeListener a,
                                 ChangeListener b)

remove

public static ChangeListener remove(ChangeListener l,
                                    ChangeListener oldl)

insertUpdate

public void insertUpdate(DocumentEvent event)
Specified by:
insertUpdate in interface DocumentListener

removeUpdate

public void removeUpdate(DocumentEvent event)
Specified by:
removeUpdate in interface DocumentListener

changedUpdate

public void changedUpdate(DocumentEvent event)
Specified by:
changedUpdate in interface DocumentListener

add

public static DocumentListener add(DocumentListener a,
                                   DocumentListener b)

remove

public static DocumentListener remove(DocumentListener l,
                                      DocumentListener oldl)

hyperlinkUpdate

public void hyperlinkUpdate(HyperlinkEvent event)
Specified by:
hyperlinkUpdate in interface HyperlinkListener

add

public static HyperlinkListener add(HyperlinkListener a,
                                    HyperlinkListener b)

remove

public static HyperlinkListener remove(HyperlinkListener l,
                                       HyperlinkListener oldl)

internalFrameOpened

public void internalFrameOpened(InternalFrameEvent event)
Specified by:
internalFrameOpened in interface InternalFrameListener

internalFrameClosing

public void internalFrameClosing(InternalFrameEvent event)
Specified by:
internalFrameClosing in interface InternalFrameListener

internalFrameClosed

public void internalFrameClosed(InternalFrameEvent event)
Specified by:
internalFrameClosed in interface InternalFrameListener

internalFrameIconified

public void internalFrameIconified(InternalFrameEvent event)
Specified by:
internalFrameIconified in interface InternalFrameListener

internalFrameDeiconified

public void internalFrameDeiconified(InternalFrameEvent event)
Specified by:
internalFrameDeiconified in interface InternalFrameListener

internalFrameActivated

public void internalFrameActivated(InternalFrameEvent event)
Specified by:
internalFrameActivated in interface InternalFrameListener

internalFrameDeactivated

public void internalFrameDeactivated(InternalFrameEvent event)
Specified by:
internalFrameDeactivated in interface InternalFrameListener

add

public static InternalFrameListener add(InternalFrameListener a,
                                        InternalFrameListener b)

remove

public static InternalFrameListener remove(InternalFrameListener l,
                                           InternalFrameListener oldl)

intervalAdded

public void intervalAdded(ListDataEvent event)
Specified by:
intervalAdded in interface ListDataListener

intervalRemoved

public void intervalRemoved(ListDataEvent event)
Specified by:
intervalRemoved in interface ListDataListener

contentsChanged

public void contentsChanged(ListDataEvent event)
Specified by:
contentsChanged in interface ListDataListener

add

public static ListDataListener add(ListDataListener a,
                                   ListDataListener b)

remove

public static ListDataListener remove(ListDataListener l,
                                      ListDataListener oldl)

valueChanged

public void valueChanged(ListSelectionEvent event)
Specified by:
valueChanged in interface ListSelectionListener

add

public static ListSelectionListener add(ListSelectionListener a,
                                        ListSelectionListener b)

remove

public static ListSelectionListener remove(ListSelectionListener l,
                                           ListSelectionListener oldl)

menuDragMouseEntered

public void menuDragMouseEntered(MenuDragMouseEvent event)
Specified by:
menuDragMouseEntered in interface MenuDragMouseListener

menuDragMouseExited

public void menuDragMouseExited(MenuDragMouseEvent event)
Specified by:
menuDragMouseExited in interface MenuDragMouseListener

menuDragMouseDragged

public void menuDragMouseDragged(MenuDragMouseEvent event)
Specified by:
menuDragMouseDragged in interface MenuDragMouseListener

menuDragMouseReleased

public void menuDragMouseReleased(MenuDragMouseEvent event)
Specified by:
menuDragMouseReleased in interface MenuDragMouseListener

add

public static MenuDragMouseListener add(MenuDragMouseListener a,
                                        MenuDragMouseListener b)

remove

public static MenuDragMouseListener remove(MenuDragMouseListener l,
                                           MenuDragMouseListener oldl)

menuKeyTyped

public void menuKeyTyped(MenuKeyEvent event)
Specified by:
menuKeyTyped in interface MenuKeyListener

menuKeyPressed

public void menuKeyPressed(MenuKeyEvent event)
Specified by:
menuKeyPressed in interface MenuKeyListener

menuKeyReleased

public void menuKeyReleased(MenuKeyEvent event)
Specified by:
menuKeyReleased in interface MenuKeyListener

add

public static MenuKeyListener add(MenuKeyListener a,
                                  MenuKeyListener b)

remove

public static MenuKeyListener remove(MenuKeyListener l,
                                     MenuKeyListener oldl)

menuSelected

public void menuSelected(MenuEvent event)
Specified by:
menuSelected in interface MenuListener

menuDeselected

public void menuDeselected(MenuEvent event)
Specified by:
menuDeselected in interface MenuListener

menuCanceled

public void menuCanceled(MenuEvent event)
Specified by:
menuCanceled in interface MenuListener

add

public static MenuListener add(MenuListener a,
                               MenuListener b)

remove

public static MenuListener remove(MenuListener l,
                                  MenuListener oldl)

popupMenuWillBecomeVisible

public void popupMenuWillBecomeVisible(PopupMenuEvent event)
Specified by:
popupMenuWillBecomeVisible in interface PopupMenuListener

popupMenuWillBecomeInvisible

public void popupMenuWillBecomeInvisible(PopupMenuEvent event)
Specified by:
popupMenuWillBecomeInvisible in interface PopupMenuListener

popupMenuCanceled

public void popupMenuCanceled(PopupMenuEvent event)
Specified by:
popupMenuCanceled in interface PopupMenuListener

add

public static PopupMenuListener add(PopupMenuListener a,
                                    PopupMenuListener b)

remove

public static PopupMenuListener remove(PopupMenuListener l,
                                       PopupMenuListener oldl)

columnAdded

public void columnAdded(TableColumnModelEvent event)
Specified by:
columnAdded in interface TableColumnModelListener

columnRemoved

public void columnRemoved(TableColumnModelEvent event)
Specified by:
columnRemoved in interface TableColumnModelListener

columnMoved

public void columnMoved(TableColumnModelEvent event)
Specified by:
columnMoved in interface TableColumnModelListener

columnMarginChanged

public void columnMarginChanged(ChangeEvent event)
Specified by:
columnMarginChanged in interface TableColumnModelListener

columnSelectionChanged

public void columnSelectionChanged(ListSelectionEvent event)
Specified by:
columnSelectionChanged in interface TableColumnModelListener

add

public static TableColumnModelListener add(TableColumnModelListener a,
                                           TableColumnModelListener b)

remove

public static TableColumnModelListener remove(TableColumnModelListener l,
                                              TableColumnModelListener oldl)

tableChanged

public void tableChanged(TableModelEvent event)
Specified by:
tableChanged in interface TableModelListener

add

public static TableModelListener add(TableModelListener a,
                                     TableModelListener b)

remove

public static TableModelListener remove(TableModelListener l,
                                        TableModelListener oldl)

treeExpanded

public void treeExpanded(TreeExpansionEvent event)
Specified by:
treeExpanded in interface TreeExpansionListener

treeCollapsed

public void treeCollapsed(TreeExpansionEvent event)
Specified by:
treeCollapsed in interface TreeExpansionListener

add

public static TreeExpansionListener add(TreeExpansionListener a,
                                        TreeExpansionListener b)

remove

public static TreeExpansionListener remove(TreeExpansionListener l,
                                           TreeExpansionListener oldl)

treeNodesChanged

public void treeNodesChanged(TreeModelEvent event)
Specified by:
treeNodesChanged in interface TreeModelListener

treeNodesInserted

public void treeNodesInserted(TreeModelEvent event)
Specified by:
treeNodesInserted in interface TreeModelListener

treeNodesRemoved

public void treeNodesRemoved(TreeModelEvent event)
Specified by:
treeNodesRemoved in interface TreeModelListener

treeStructureChanged

public void treeStructureChanged(TreeModelEvent event)
Specified by:
treeStructureChanged in interface TreeModelListener

add

public static TreeModelListener add(TreeModelListener a,
                                    TreeModelListener b)

remove

public static TreeModelListener remove(TreeModelListener l,
                                       TreeModelListener oldl)

valueChanged

public void valueChanged(TreeSelectionEvent event)
Specified by:
valueChanged in interface TreeSelectionListener

add

public static TreeSelectionListener add(TreeSelectionListener a,
                                        TreeSelectionListener b)

remove

public static TreeSelectionListener remove(TreeSelectionListener l,
                                           TreeSelectionListener oldl)

treeWillExpand

public void treeWillExpand(TreeExpansionEvent event)
                    throws ExpandVetoException
Specified by:
treeWillExpand in interface TreeWillExpandListener
Throws:
ExpandVetoException

treeWillCollapse

public void treeWillCollapse(TreeExpansionEvent event)
                      throws ExpandVetoException
Specified by:
treeWillCollapse in interface TreeWillExpandListener
Throws:
ExpandVetoException

add

public static TreeWillExpandListener add(TreeWillExpandListener a,
                                         TreeWillExpandListener b)

remove

public static TreeWillExpandListener remove(TreeWillExpandListener l,
                                            TreeWillExpandListener oldl)

undoableEditHappened

public void undoableEditHappened(UndoableEditEvent event)
Specified by:
undoableEditHappened in interface UndoableEditListener

add

public static UndoableEditListener add(UndoableEditListener a,
                                       UndoableEditListener b)

remove

public static UndoableEditListener remove(UndoableEditListener l,
                                          UndoableEditListener oldl)

addInternal

protected static EventListener addInternal(EventListener a,
                                           EventListener b)

removeInternal

protected static EventListener removeInternal(EventListener l,
                                              EventListener oldl)


Copyright © 1996-2013 FreeHEP. All Rights Reserved.