Exemple #1
0
  /**
   * Serializes this <code>DragSource</code>. This method first performs default serialization.
   * Next, it writes out this object's <code>FlavorMap</code> if and only if it can be serialized.
   * If not, <code>null</code> is written instead. Next, it writes out <code>Serializable</code>
   * listeners registered with this object. Listeners are written in a <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 the <code>Object</code> and is one of
   * the following:
   *
   * <ul>
   *   <li><code>dragSourceListenerK</code> indicating a <code>DragSourceListener</code> object;
   *   <li><code>dragSourceMotionListenerK</code> indicating a <code>DragSourceMotionListener</code>
   *       object.
   * </ul>
   *
   * @serialData Either a <code>FlavorMap</code> instance, or <code>null</code>, followed by a
   *     <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 the
   *     <code>Object</code> and is one of the following:
   *     <ul>
   *       <li><code>dragSourceListenerK</code> indicating a <code>DragSourceListener</code> object;
   *       <li><code>dragSourceMotionListenerK</code> indicating a <code>DragSourceMotionListener
   *           </code> object.
   *     </ul>
   *     .
   * @since 1.4
   */
  private void writeObject(ObjectOutputStream s) throws IOException {
    s.defaultWriteObject();

    s.writeObject(SerializationTester.test(flavorMap) ? flavorMap : null);

    DnDEventMulticaster.save(s, dragSourceListenerK, listener);
    DnDEventMulticaster.save(s, dragSourceMotionListenerK, motionListener);
    s.writeObject(null);
  }
Exemple #2
0
 /**
  * Removes the specified <code>DragSourceMotionListener</code> from this <code>DragSource</code>.
  * If a <code>null</code> listener is specified, no action is taken and no exception is thrown. If
  * the listener specified by the argument was not previously added to this <code>DragSource</code>
  * , no action is taken and no exception is thrown.
  *
  * @param dsml the <code>DragSourceMotionListener</code> to remove
  * @see #addDragSourceMotionListener
  * @see #getDragSourceMotionListeners
  * @since 1.4
  */
 public void removeDragSourceMotionListener(DragSourceMotionListener dsml) {
   if (dsml != null) {
     synchronized (this) {
       motionListener = DnDEventMulticaster.remove(motionListener, dsml);
     }
   }
 }
Exemple #3
0
 /**
  * Removes the specified <code>DragSourceListener</code> from this <code>DragSource</code>. If a
  * <code>null</code> listener is specified, no action is taken and no exception is thrown. If the
  * listener specified by the argument was not previously added to this <code>DragSource</code>, no
  * action is taken and no exception is thrown.
  *
  * @param dsl the <code>DragSourceListener</code> to remove
  * @see #addDragSourceListener
  * @see #getDragSourceListeners
  * @since 1.4
  */
 public void removeDragSourceListener(DragSourceListener dsl) {
   if (dsl != null) {
     synchronized (this) {
       listener = DnDEventMulticaster.remove(listener, dsl);
     }
   }
 }
Exemple #4
0
 /**
  * Gets all the objects currently registered as <code><em>Foo</em>Listener</code>s upon this
  * <code>DragSource</code>. <code><em>Foo</em>Listener</code>s are registered using the <code>
  * add<em>Foo</em>Listener</code> method.
  *
  * @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 <code>
  *     DragSource</code>, or an empty array if no such listeners have been added
  * @exception <code>ClassCastException</code> if <code>listenerType</code> doesn't specify a class
  *     or interface that implements <code>java.util.EventListener</code>
  * @see #getDragSourceListeners
  * @see #getDragSourceMotionListeners
  * @since 1.4
  */
 public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
   EventListener l = null;
   if (listenerType == DragSourceListener.class) {
     l = listener;
   } else if (listenerType == DragSourceMotionListener.class) {
     l = motionListener;
   }
   return DnDEventMulticaster.getListeners(l, listenerType);
 }