示例#1
0
 /**
  * Adds the specified action listener to receive action events from this text field. If l is null,
  * no exception is thrown and no action is performed.
  *
  * @param l the action listener.
  * @see #removeActionListener
  * @see #getActionListeners
  * @see java.awt.event.ActionListener
  * @since JDK1.1
  */
 public synchronized void addActionListener(ActionListener l) {
   if (l == null) {
     return;
   }
   actionListener = AWTEventMulticaster.add(actionListener, l);
   newEventsOnly = true;
 }
示例#2
0
 /**
  * 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.
  *
  * <p>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.
  *
  * @param listenerType the type of listeners requested; this parameter should specify an interface
  *     that descends from <code>java.util.EventListener</code>
  * @return 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
  * @exception ClassCastException if <code>listenerType</code> doesn't specify a class or interface
  *     that implements <code>java.util.EventListener</code>
  * @see #getActionListeners
  * @since 1.3
  */
 public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
   EventListener l = null;
   if (listenerType == ActionListener.class) {
     l = actionListener;
   }
   return AWTEventMulticaster.getListeners(l, listenerType);
 }
示例#3
0
  /**
   * Writes default serializable fields to stream. Writes a list of serializable ActionListener(s)
   * as optional data. The non-serializable ActionListener(s) are detected and no attempt is made to
   * serialize them.
   *
   * @serialData Null terminated sequence of zero or more pairs. A pair consists of a String and
   *     Object. The String indicates the type of object and is one of the following :
   *     ActionListenerK indicating and ActionListener object.
   * @see AWTEventMulticaster#save(ObjectOutputStream, String, EventListener)
   * @see java.awt.Component#actionListenerK
   */
  private void writeObject(ObjectOutputStream s) throws IOException {
    s.defaultWriteObject();

    AWTEventMulticaster.save(s, actionListenerK, actionListener);
    s.writeObject(null);
  }
示例#4
0
 /**
  * Removes the specified action listener so that it no longer receives action events from this
  * text field. If l is null, no exception is thrown and no action is performed.
  *
  * @param l the action listener.
  * @see #addActionListener
  * @see #getActionListeners
  * @see java.awt.event.ActionListener
  * @since JDK1.1
  */
 public synchronized void removeActionListener(ActionListener l) {
   if (l == null) {
     return;
   }
   actionListener = AWTEventMulticaster.remove(actionListener, l);
 }