Exemple #1
0
        /// <summary>
        /// Writes default serializable fields to stream.  Writes
        /// a list of serializable <code>ItemListeners</code>
        /// as optional data.  The non-serializable
        /// <code>ItemListeners</code> are detected and
        /// no attempt is made to serialize them.
        /// </summary>
        /// <param name="s"> the <code>ObjectOutputStream</code> to write
        /// @serialData <code>null</code> terminated sequence of
        ///  0 or more pairs; the pair consists of a <code>String</code>
        ///  and an <code>Object</code>; the <code>String</code> indicates
        ///  the type of object and is one of the following:
        ///  <code>itemListenerK</code> indicating an
        ///    <code>ItemListener</code> object
        /// </param>
        /// <seealso cref= AWTEventMulticaster#save(ObjectOutputStream, String, EventListener) </seealso>
        /// <seealso cref= java.awt.Component#itemListenerK </seealso>
        /// <seealso cref= #readObject(ObjectInputStream) </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException
        private void WriteObject(ObjectOutputStream s)
        {
            s.DefaultWriteObject();

            AWTEventMulticaster.Save(s, ItemListenerK, ItemListener);
            s.WriteObject(null);
        }
Exemple #2
0
        /// <summary>
        /// Returns an array of all the objects currently registered
        /// as <code><em>Foo</em>Listener</code>s
        /// upon this <code>MenuItem</code>.
        /// <code><em>Foo</em>Listener</code>s are registered using the
        /// <code>add<em>Foo</em>Listener</code> method.
        ///
        /// <para>
        /// You can specify the <code>listenerType</code> argument
        /// with a class literal, such as
        /// <code><em>Foo</em>Listener.class</code>.
        /// For example, you can query a
        /// <code>MenuItem</code> <code>m</code>
        /// for its action listeners with the following code:
        ///
        /// <pre>ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));</pre>
        ///
        /// If no such listeners exist, this method returns an empty array.
        ///
        /// </para>
        /// </summary>
        /// <param name="listenerType"> the type of listeners requested; this parameter
        ///          should specify an interface that descends from
        ///          <code>java.util.EventListener</code> </param>
        /// <returns> an array of all objects registered as
        ///          <code><em>Foo</em>Listener</code>s on this menu item,
        ///          or an empty array if no such
        ///          listeners have been added </returns>
        /// <exception cref="ClassCastException"> if <code>listenerType</code>
        ///          doesn't specify a class or interface that implements
        ///          <code>java.util.EventListener</code>
        /// </exception>
        /// <seealso cref= #getActionListeners
        /// @since 1.3 </seealso>
        public virtual T[] getListeners <T>(Class listenerType) where T : java.util.EventListener
        {
            EventListener l = null;

            if (listenerType == typeof(ActionListener))
            {
                l = ActionListener;
            }
            return(AWTEventMulticaster.GetListeners(l, listenerType));
        }
Exemple #3
0
 /// <summary>
 /// Removes the specified item listener so that it no longer receives
 /// item events from this check box menu item.
 /// If l is null, no exception is thrown and no action is performed.
 /// <para>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
 /// >AWT Threading Issues</a> for details on AWT's threading model.
 ///
 /// </para>
 /// </summary>
 /// <param name="l"> the item listener </param>
 /// <seealso cref=           #addItemListener </seealso>
 /// <seealso cref=           #getItemListeners </seealso>
 /// <seealso cref=           java.awt.event.ItemEvent </seealso>
 /// <seealso cref=           java.awt.event.ItemListener
 /// @since         JDK1.1 </seealso>
 public virtual void RemoveItemListener(ItemListener l)
 {
     lock (this)
     {
         if (l == null)
         {
             return;
         }
         ItemListener = AWTEventMulticaster.Remove(ItemListener, l);
     }
 }
Exemple #4
0
 /// <summary>
 /// Removes the specified action listener so that it no longer
 /// receives action events from this button. Action events occur
 /// when a user presses or releases the mouse over this button.
 /// If l is null, no exception is thrown and no action is performed.
 /// <para>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
 /// >AWT Threading Issues</a> for details on AWT's threading model.
 ///
 /// </para>
 /// </summary>
 /// <param name="l">     the action listener </param>
 /// <seealso cref=             #addActionListener </seealso>
 /// <seealso cref=             #getActionListeners </seealso>
 /// <seealso cref=             java.awt.event.ActionListener
 /// @since           JDK1.1 </seealso>
 public virtual void RemoveActionListener(ActionListener l)
 {
     lock (this)
     {
         if (l == null)
         {
             return;
         }
         ActionListener = AWTEventMulticaster.Remove(ActionListener, l);
     }
 }
Exemple #5
0
 /// <summary>
 /// Adds the specified adjustment listener to receive adjustment
 /// events from this <code>ScrollPaneAdjustable</code>.
 /// If <code>l</code> is <code>null</code>, no exception is thrown
 /// and no action is performed.
 /// <para>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
 /// >AWT Threading Issues</a> for details on AWT's threading model.
 ///
 /// </para>
 /// </summary>
 /// <param name="l">   the adjustment listener. </param>
 /// <seealso cref=      #removeAdjustmentListener </seealso>
 /// <seealso cref=      #getAdjustmentListeners </seealso>
 /// <seealso cref=      java.awt.event.AdjustmentListener </seealso>
 /// <seealso cref=      java.awt.event.AdjustmentEvent </seealso>
 public virtual void AddAdjustmentListener(AdjustmentListener l)
 {
     lock (this)
     {
         if (l == null)
         {
             return;
         }
         AdjustmentListener = AWTEventMulticaster.Add(AdjustmentListener, l);
     }
 }
Exemple #6
0
 /// <summary>
 /// Adds the specified action listener to receive
 /// <code>ActionEvent</code>s from this <code>TrayIcon</code>.
 /// Action events usually occur when a user selects the tray icon,
 /// using either the mouse or keyboard.  The conditions in which
 /// action events are generated are platform-dependent.
 ///
 /// <para>Calling this method with a <code>null</code> value has no
 /// effect.
 /// </para>
 /// <para>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
 /// >AWT Threading Issues</a> for details on AWT's threading model.
 ///
 /// </para>
 /// </summary>
 /// <param name="listener"> the action listener </param>
 /// <seealso cref=           #removeActionListener </seealso>
 /// <seealso cref=           #getActionListeners </seealso>
 /// <seealso cref=           java.awt.event.ActionListener </seealso>
 /// <seealso cref= #setActionCommand(String) </seealso>
 public virtual void AddActionListener(ActionListener listener)
 {
     lock (this)
     {
         if (listener == null)
         {
             return;
         }
         ActionListener = AWTEventMulticaster.Add(ActionListener, listener);
     }
 }
Exemple #7
0
 /// <summary>
 /// Removes the specified mouse-motion listener.  Calling this method with
 /// <code>null</code> or an invalid value has no effect.
 /// <para>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
 /// >AWT Threading Issues</a> for details on AWT's threading model.
 ///
 /// </para>
 /// </summary>
 /// <param name="listener">   the mouse listener </param>
 /// <seealso cref=      java.awt.event.MouseEvent </seealso>
 /// <seealso cref=      java.awt.event.MouseMotionListener </seealso>
 /// <seealso cref=      #addMouseMotionListener(MouseMotionListener) </seealso>
 /// <seealso cref=      #getMouseMotionListeners </seealso>
 public virtual void RemoveMouseMotionListener(MouseMotionListener listener)
 {
     lock (this)
     {
         if (listener == null)
         {
             return;
         }
         MouseMotionListener = AWTEventMulticaster.Remove(MouseMotionListener, listener);
     }
 }
Exemple #8
0
 /// <summary>
 /// Adds the specified mouse listener to receive mouse events from
 /// this <code>TrayIcon</code>.  Calling this method with a
 /// <code>null</code> value has no effect.
 ///
 /// <para><b>Note</b>: The {@code MouseEvent}'s coordinates (received
 /// from the {@code TrayIcon}) are relative to the screen, not the
 /// {@code TrayIcon}.
 ///
 /// </para>
 /// <para> <b>Note: </b>The <code>MOUSE_ENTERED</code> and
 /// <code>MOUSE_EXITED</code> mouse events are not supported.
 /// </para>
 /// <para>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
 /// >AWT Threading Issues</a> for details on AWT's threading model.
 ///
 /// </para>
 /// </summary>
 /// <param name="listener"> the mouse listener </param>
 /// <seealso cref=      java.awt.event.MouseEvent </seealso>
 /// <seealso cref=      java.awt.event.MouseListener </seealso>
 /// <seealso cref=      #removeMouseListener(MouseListener) </seealso>
 /// <seealso cref=      #getMouseListeners </seealso>
 public virtual void AddMouseListener(MouseListener listener)
 {
     lock (this)
     {
         if (listener == null)
         {
             return;
         }
         MouseListener = AWTEventMulticaster.Add(MouseListener, listener);
     }
 }
Exemple #9
0
 /// <summary>
 /// Adds the specified item listener to receive item events from
 /// this check box menu item.  Item events are sent in response to user
 /// actions, but not in response to calls to setState().
 /// If l is null, no exception is thrown and no action is performed.
 /// <para>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
 /// >AWT Threading Issues</a> for details on AWT's threading model.
 ///
 /// </para>
 /// </summary>
 /// <param name="l"> the item listener </param>
 /// <seealso cref=           #removeItemListener </seealso>
 /// <seealso cref=           #getItemListeners </seealso>
 /// <seealso cref=           #setState </seealso>
 /// <seealso cref=           java.awt.event.ItemEvent </seealso>
 /// <seealso cref=           java.awt.event.ItemListener
 /// @since         JDK1.1 </seealso>
 public virtual void AddItemListener(ItemListener l)
 {
     lock (this)
     {
         if (l == null)
         {
             return;
         }
         ItemListener  = AWTEventMulticaster.Add(ItemListener, l);
         NewEventsOnly = true;
     }
 }
Exemple #10
0
 /*
  * Recursive method which returns a count of the number of listeners in
  * EventListener, handling the (common) case of l actually being an
  * AWTEventMulticaster.  Additionally, only listeners of type listenerType
  * are counted.  Method modified to fix bug 4513402.  -bchristi
  */
 private static int GetListenerCount(EventListener l, Class listenerType)
 {
     if (l is AWTEventMulticaster)
     {
         AWTEventMulticaster mc = (AWTEventMulticaster)l;
         return(GetListenerCount(mc.a, listenerType) + GetListenerCount(mc.b, listenerType));
     }
     else
     {
         // Only count listeners of correct type
         return(listenerType.isInstance(l) ? 1 : 0);
     }
 }
Exemple #11
0
        /// <summary>
        /// Returns an array of all the objects currently registered
        /// as <code><em>Foo</em>Listener</code>s
        /// upon this <code>CheckboxMenuItem</code>.
        /// <code><em>Foo</em>Listener</code>s are registered using the
        /// <code>add<em>Foo</em>Listener</code> method.
        ///
        /// <para>
        /// You can specify the <code>listenerType</code> argument
        /// with a class literal, such as
        /// <code><em>Foo</em>Listener.class</code>.
        /// For example, you can query a
        /// <code>CheckboxMenuItem</code> <code>c</code>
        /// for its item listeners with the following code:
        ///
        /// <pre>ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));</pre>
        ///
        /// If no such listeners exist, this method returns an empty array.
        ///
        /// </para>
        /// </summary>
        /// <param name="listenerType"> the type of listeners requested; this parameter
        ///          should specify an interface that descends from
        ///          <code>java.util.EventListener</code> </param>
        /// <returns> an array of all objects registered as
        ///          <code><em>Foo</em>Listener</code>s on this checkbox menuitem,
        ///          or an empty array if no such
        ///          listeners have been added </returns>
        /// <exception cref="ClassCastException"> if <code>listenerType</code>
        ///          doesn't specify a class or interface that implements
        ///          <code>java.util.EventListener</code>
        /// </exception>
        /// <seealso cref= #getItemListeners
        /// @since 1.3 </seealso>
        public override T[] getListeners <T>(Class listenerType) where T : java.util.EventListener
        {
            EventListener l = null;

            if (listenerType == typeof(ItemListener))
            {
                l = ItemListener;
            }
            else
            {
                return(base.GetListeners(listenerType));
            }
            return(AWTEventMulticaster.GetListeners(l, listenerType));
        }
Exemple #12
0
 /*
  * Recusive method which populates EventListener array a with EventListeners
  * from l.  l is usually an AWTEventMulticaster.  Bug 4513402 revealed that
  * if l differed in type from the element type of a, an ArrayStoreException
  * would occur.  Now l is only inserted into a if it's of the appropriate
  * type.  -bchristi
  */
 private static int PopulateListenerArray(EventListener[] a, EventListener l, int index)
 {
     if (l is AWTEventMulticaster)
     {
         AWTEventMulticaster mc = (AWTEventMulticaster)l;
         int lhs = PopulateListenerArray(a, mc.a, index);
         return(PopulateListenerArray(a, mc.b, lhs));
     }
     else if (a.GetType().GetElementType().isInstance(l))
     {
         a[index] = l;
         return(index + 1);
     }
     // Skip nulls, instances of wrong class
     else
     {
         return(index);
     }
 }