src/share/classes/java/awt/AWTEventMulticaster.java
Print this page
@@ -108,11 +108,19 @@
MouseListener, MouseMotionListener, WindowListener, WindowFocusListener,
WindowStateListener, ActionListener, ItemListener, AdjustmentListener,
TextListener, InputMethodListener, HierarchyListener,
HierarchyBoundsListener, MouseWheelListener {
- protected final EventListener a, b;
+ /**
+ * A variable in the event chain (listener-a)
+ */
+ protected final EventListener a;
+
+ /**
+ * A variable in the event chain (listener-b)
+ */
+ protected final EventListener b;
/**
* Creates an event multicaster instance which chains listener-a
* with listener-b. Input parameters <code>a</code> and <code>b</code>
* should not be <code>null</code>, though implementations may vary in
@@ -535,80 +543,88 @@
/**
* Adds component-listener-a with component-listener-b and
* returns the resulting multicast listener.
* @param a component-listener-a
* @param b component-listener-b
+ * @return the resulting listener
*/
public static ComponentListener add(ComponentListener a, ComponentListener b) {
return (ComponentListener)addInternal(a, b);
}
/**
* Adds container-listener-a with container-listener-b and
* returns the resulting multicast listener.
* @param a container-listener-a
* @param b container-listener-b
+ * @return the resulting listener
*/
public static ContainerListener add(ContainerListener a, ContainerListener b) {
return (ContainerListener)addInternal(a, b);
}
/**
* Adds focus-listener-a with focus-listener-b and
* returns the resulting multicast listener.
* @param a focus-listener-a
* @param b focus-listener-b
+ * @return the resulting listener
*/
public static FocusListener add(FocusListener a, FocusListener b) {
return (FocusListener)addInternal(a, b);
}
/**
* Adds key-listener-a with key-listener-b and
* returns the resulting multicast listener.
* @param a key-listener-a
* @param b key-listener-b
+ * @return the resulting listener
*/
public static KeyListener add(KeyListener a, KeyListener b) {
return (KeyListener)addInternal(a, b);
}
/**
* Adds mouse-listener-a with mouse-listener-b and
* returns the resulting multicast listener.
* @param a mouse-listener-a
* @param b mouse-listener-b
+ * @return the resulting listener
*/
public static MouseListener add(MouseListener a, MouseListener b) {
return (MouseListener)addInternal(a, b);
}
/**
* Adds mouse-motion-listener-a with mouse-motion-listener-b and
* returns the resulting multicast listener.
* @param a mouse-motion-listener-a
* @param b mouse-motion-listener-b
+ * @return the resulting listener
*/
public static MouseMotionListener add(MouseMotionListener a, MouseMotionListener b) {
return (MouseMotionListener)addInternal(a, b);
}
/**
* Adds window-listener-a with window-listener-b and
* returns the resulting multicast listener.
* @param a window-listener-a
* @param b window-listener-b
+ * @return the resulting listener
*/
public static WindowListener add(WindowListener a, WindowListener b) {
return (WindowListener)addInternal(a, b);
}
/**
* Adds window-state-listener-a with window-state-listener-b
* and returns the resulting multicast listener.
* @param a window-state-listener-a
* @param b window-state-listener-b
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
public static WindowStateListener add(WindowStateListener a,
WindowStateListener b) {
@@ -618,10 +634,11 @@
/**
* Adds window-focus-listener-a with window-focus-listener-b
* and returns the resulting multicast listener.
* @param a window-focus-listener-a
* @param b window-focus-listener-b
+ * @return the resulting listener
* @since 1.4
*/
public static WindowFocusListener add(WindowFocusListener a,
WindowFocusListener b) {
return (WindowFocusListener)addInternal(a, b);
@@ -630,10 +647,11 @@
/**
* Adds action-listener-a with action-listener-b and
* returns the resulting multicast listener.
* @param a action-listener-a
* @param b action-listener-b
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ActionListener add(ActionListener a, ActionListener b) {
return (ActionListener)addInternal(a, b);
}
@@ -641,10 +659,11 @@
/**
* Adds item-listener-a with item-listener-b and
* returns the resulting multicast listener.
* @param a item-listener-a
* @param b item-listener-b
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ItemListener add(ItemListener a, ItemListener b) {
return (ItemListener)addInternal(a, b);
}
@@ -652,35 +671,46 @@
/**
* Adds adjustment-listener-a with adjustment-listener-b and
* returns the resulting multicast listener.
* @param a adjustment-listener-a
* @param b adjustment-listener-b
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static AdjustmentListener add(AdjustmentListener a, AdjustmentListener b) {
return (AdjustmentListener)addInternal(a, b);
}
+
+ /**
+ * Adds text-listener-a with text-listener-b and
+ * returns the resulting multicast listener.
+ * @param a text-listener-a
+ * @param b text-listener-b
+ * @return the resulting listener
+ */
@SuppressWarnings("overloads")
public static TextListener add(TextListener a, TextListener b) {
return (TextListener)addInternal(a, b);
}
/**
* Adds input-method-listener-a with input-method-listener-b and
* returns the resulting multicast listener.
* @param a input-method-listener-a
* @param b input-method-listener-b
+ * @return the resulting listener
*/
public static InputMethodListener add(InputMethodListener a, InputMethodListener b) {
return (InputMethodListener)addInternal(a, b);
}
/**
* Adds hierarchy-listener-a with hierarchy-listener-b and
* returns the resulting multicast listener.
* @param a hierarchy-listener-a
* @param b hierarchy-listener-b
+ * @return the resulting listener
* @since 1.3
*/
@SuppressWarnings("overloads")
public static HierarchyListener add(HierarchyListener a, HierarchyListener b) {
return (HierarchyListener)addInternal(a, b);
@@ -689,10 +719,11 @@
/**
* Adds hierarchy-bounds-listener-a with hierarchy-bounds-listener-b and
* returns the resulting multicast listener.
* @param a hierarchy-bounds-listener-a
* @param b hierarchy-bounds-listener-b
+ * @return the resulting listener
* @since 1.3
*/
public static HierarchyBoundsListener add(HierarchyBoundsListener a, HierarchyBoundsListener b) {
return (HierarchyBoundsListener)addInternal(a, b);
}
@@ -700,10 +731,11 @@
/**
* Adds mouse-wheel-listener-a with mouse-wheel-listener-b and
* returns the resulting multicast listener.
* @param a mouse-wheel-listener-a
* @param b mouse-wheel-listener-b
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
public static MouseWheelListener add(MouseWheelListener a,
MouseWheelListener b) {
@@ -713,80 +745,88 @@
/**
* Removes the old component-listener from component-listener-l and
* returns the resulting multicast listener.
* @param l component-listener-l
* @param oldl the component-listener being removed
+ * @return the resulting listener
*/
public static ComponentListener remove(ComponentListener l, ComponentListener oldl) {
return (ComponentListener) removeInternal(l, oldl);
}
/**
* Removes the old container-listener from container-listener-l and
* returns the resulting multicast listener.
* @param l container-listener-l
* @param oldl the container-listener being removed
+ * @return the resulting listener
*/
public static ContainerListener remove(ContainerListener l, ContainerListener oldl) {
return (ContainerListener) removeInternal(l, oldl);
}
/**
* Removes the old focus-listener from focus-listener-l and
* returns the resulting multicast listener.
* @param l focus-listener-l
* @param oldl the focus-listener being removed
+ * @return the resulting listener
*/
public static FocusListener remove(FocusListener l, FocusListener oldl) {
return (FocusListener) removeInternal(l, oldl);
}
/**
* Removes the old key-listener from key-listener-l and
* returns the resulting multicast listener.
* @param l key-listener-l
* @param oldl the key-listener being removed
+ * @return the resulting listener
*/
public static KeyListener remove(KeyListener l, KeyListener oldl) {
return (KeyListener) removeInternal(l, oldl);
}
/**
* Removes the old mouse-listener from mouse-listener-l and
* returns the resulting multicast listener.
* @param l mouse-listener-l
* @param oldl the mouse-listener being removed
+ * @return the resulting listener
*/
public static MouseListener remove(MouseListener l, MouseListener oldl) {
return (MouseListener) removeInternal(l, oldl);
}
/**
* Removes the old mouse-motion-listener from mouse-motion-listener-l
* and returns the resulting multicast listener.
* @param l mouse-motion-listener-l
* @param oldl the mouse-motion-listener being removed
+ * @return the resulting listener
*/
public static MouseMotionListener remove(MouseMotionListener l, MouseMotionListener oldl) {
return (MouseMotionListener) removeInternal(l, oldl);
}
/**
* Removes the old window-listener from window-listener-l and
* returns the resulting multicast listener.
* @param l window-listener-l
* @param oldl the window-listener being removed
+ * @return the resulting listener
*/
public static WindowListener remove(WindowListener l, WindowListener oldl) {
return (WindowListener) removeInternal(l, oldl);
}
/**
* Removes the old window-state-listener from window-state-listener-l
* and returns the resulting multicast listener.
* @param l window-state-listener-l
* @param oldl the window-state-listener being removed
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
public static WindowStateListener remove(WindowStateListener l,
WindowStateListener oldl) {
@@ -796,10 +836,11 @@
/**
* Removes the old window-focus-listener from window-focus-listener-l
* and returns the resulting multicast listener.
* @param l window-focus-listener-l
* @param oldl the window-focus-listener being removed
+ * @return the resulting listener
* @since 1.4
*/
public static WindowFocusListener remove(WindowFocusListener l,
WindowFocusListener oldl) {
return (WindowFocusListener) removeInternal(l, oldl);
@@ -808,10 +849,11 @@
/**
* Removes the old action-listener from action-listener-l and
* returns the resulting multicast listener.
* @param l action-listener-l
* @param oldl the action-listener being removed
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ActionListener remove(ActionListener l, ActionListener oldl) {
return (ActionListener) removeInternal(l, oldl);
}
@@ -819,10 +861,11 @@
/**
* Removes the old item-listener from item-listener-l and
* returns the resulting multicast listener.
* @param l item-listener-l
* @param oldl the item-listener being removed
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ItemListener remove(ItemListener l, ItemListener oldl) {
return (ItemListener) removeInternal(l, oldl);
}
@@ -830,35 +873,46 @@
/**
* Removes the old adjustment-listener from adjustment-listener-l and
* returns the resulting multicast listener.
* @param l adjustment-listener-l
* @param oldl the adjustment-listener being removed
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static AdjustmentListener remove(AdjustmentListener l, AdjustmentListener oldl) {
return (AdjustmentListener) removeInternal(l, oldl);
}
+
+ /**
+ * Removes the old text-listener from text-listener-l and
+ * returns the resulting multicast listener.
+ * @param l text-listener-l
+ * @param oldl the text-listener being removed
+ * @return the resulting listener
+ */
@SuppressWarnings("overloads")
public static TextListener remove(TextListener l, TextListener oldl) {
return (TextListener) removeInternal(l, oldl);
}
/**
* Removes the old input-method-listener from input-method-listener-l and
* returns the resulting multicast listener.
* @param l input-method-listener-l
* @param oldl the input-method-listener being removed
+ * @return the resulting listener
*/
public static InputMethodListener remove(InputMethodListener l, InputMethodListener oldl) {
return (InputMethodListener) removeInternal(l, oldl);
}
/**
* Removes the old hierarchy-listener from hierarchy-listener-l and
* returns the resulting multicast listener.
* @param l hierarchy-listener-l
* @param oldl the hierarchy-listener being removed
+ * @return the resulting listener
* @since 1.3
*/
@SuppressWarnings("overloads")
public static HierarchyListener remove(HierarchyListener l, HierarchyListener oldl) {
return (HierarchyListener) removeInternal(l, oldl);
@@ -868,10 +922,11 @@
* Removes the old hierarchy-bounds-listener from
* hierarchy-bounds-listener-l and returns the resulting multicast
* listener.
* @param l hierarchy-bounds-listener-l
* @param oldl the hierarchy-bounds-listener being removed
+ * @return the resulting listener
* @since 1.3
*/
public static HierarchyBoundsListener remove(HierarchyBoundsListener l, HierarchyBoundsListener oldl) {
return (HierarchyBoundsListener) removeInternal(l, oldl);
}
@@ -879,10 +934,11 @@
/**
* Removes the old mouse-wheel-listener from mouse-wheel-listener-l
* and returns the resulting multicast listener.
* @param l mouse-wheel-listener-l
* @param oldl the mouse-wheel-listener being removed
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
public static MouseWheelListener remove(MouseWheelListener l,
MouseWheelListener oldl) {
@@ -896,10 +952,11 @@
* If listener-b is null, it returns listener-a
* If neither are null, then it creates and returns
* a new AWTEventMulticaster instance which chains a with b.
* @param a event listener-a
* @param b event listener-b
+ * @return the resulting listener
*/
protected static EventListener addInternal(EventListener a, EventListener b) {
if (a == null) return b;
if (b == null) return a;
return new AWTEventMulticaster(a, b);
@@ -913,10 +970,11 @@
* Else if listener-l is an instance of AWTEventMulticaster,
* then it removes the old listener from it.
* Else, returns listener l.
* @param l the listener being removed from
* @param oldl the listener being removed
+ * @return the resulting listener
*/
protected static EventListener removeInternal(EventListener l, EventListener oldl) {
if (l == oldl || l == null) {
return null;
} else if (l instanceof AWTEventMulticaster) {
@@ -925,13 +983,17 @@
return l; // it's not here
}
}
- /* Serialization support.
+ /**
+ * Serialization support. Saves all Serializable listeners to a serialization stream.
+ *
+ * @param s the stream to save to
+ * @param k a prefix stream to put before each serializable listener
+ * @throws IOException if serialization fails
*/
-
protected void saveInternal(ObjectOutputStream s, String k) throws IOException {
if (a instanceof AWTEventMulticaster) {
((AWTEventMulticaster)a).saveInternal(s, k);
}
else if (a instanceof Serializable) {
@@ -946,10 +1008,18 @@
s.writeObject(k);
s.writeObject(b);
}
}
+ /**
+ * Saves a Serializable listener chain to a serialization stream.
+ *
+ * @param s the stream to save to
+ * @param k a prefix stream to put before each serializable listener
+ * @param l the listener chain to save
+ * @throws IOException if serialization fails
+ */
protected static void save(ObjectOutputStream s, String k, EventListener l) throws IOException {
if (l == null) {
return;
}
else if (l instanceof AWTEventMulticaster) {