583 if (dsl != null) {
584 synchronized (this) {
585 listener = DnDEventMulticaster.remove(listener, dsl);
586 }
587 }
588 }
589
590 /**
591 * Gets all the <code>DragSourceListener</code>s
592 * registered with this <code>DragSource</code>.
593 *
594 * @return all of this <code>DragSource</code>'s
595 * <code>DragSourceListener</code>s or an empty array if no
596 * such listeners are currently registered
597 *
598 * @see #addDragSourceListener
599 * @see #removeDragSourceListener
600 * @since 1.4
601 */
602 public DragSourceListener[] getDragSourceListeners() {
603 return (DragSourceListener[])getListeners(DragSourceListener.class);
604 }
605
606 /**
607 * Adds the specified <code>DragSourceMotionListener</code> to this
608 * <code>DragSource</code> to receive drag motion events during drag
609 * operations intiated with this <code>DragSource</code>.
610 * If a <code>null</code> listener is specified, no action is taken and no
611 * exception is thrown.
612 *
613 * @param dsml the <code>DragSourceMotionListener</code> to add
614 *
615 * @see #removeDragSourceMotionListener
616 * @see #getDragSourceMotionListeners
617 * @since 1.4
618 */
619 public void addDragSourceMotionListener(DragSourceMotionListener dsml) {
620 if (dsml != null) {
621 synchronized (this) {
622 motionListener = DnDEventMulticaster.add(motionListener, dsml);
623 }
643 if (dsml != null) {
644 synchronized (this) {
645 motionListener = DnDEventMulticaster.remove(motionListener, dsml);
646 }
647 }
648 }
649
650 /**
651 * Gets all of the <code>DragSourceMotionListener</code>s
652 * registered with this <code>DragSource</code>.
653 *
654 * @return all of this <code>DragSource</code>'s
655 * <code>DragSourceMotionListener</code>s or an empty array if no
656 * such listeners are currently registered
657 *
658 * @see #addDragSourceMotionListener
659 * @see #removeDragSourceMotionListener
660 * @since 1.4
661 */
662 public DragSourceMotionListener[] getDragSourceMotionListeners() {
663 return (DragSourceMotionListener[])
664 getListeners(DragSourceMotionListener.class);
665 }
666
667 /**
668 * Gets all the objects currently registered as
669 * <code><em>Foo</em>Listener</code>s upon this <code>DragSource</code>.
670 * <code><em>Foo</em>Listener</code>s are registered using the
671 * <code>add<em>Foo</em>Listener</code> method.
672 *
673 * @param listenerType the type of listeners requested; this parameter
674 * should specify an interface that descends from
675 * <code>java.util.EventListener</code>
676 * @return an array of all objects registered as
677 * <code><em>Foo</em>Listener</code>s on this
678 * <code>DragSource</code>, or an empty array if no such listeners
679 * have been added
680 * @exception <code>ClassCastException</code> if <code>listenerType</code>
681 * doesn't specify a class or interface that implements
682 * <code>java.util.EventListener</code>
683 *
684 * @see #getDragSourceListeners
879 }
880 }
881
882 /**
883 * Returns the drag gesture motion threshold. The drag gesture motion threshold
884 * defines the recommended behavior for {@link MouseDragGestureRecognizer}s.
885 * <p>
886 * If the system property <code>awt.dnd.drag.threshold</code> is set to
887 * a positive integer, this method returns the value of the system property;
888 * otherwise if a pertinent desktop property is available and supported by
889 * the implementation of the Java platform, this method returns the value of
890 * that property; otherwise this method returns some default value.
891 * The pertinent desktop property can be queried using
892 * <code>java.awt.Toolkit.getDesktopProperty("DnD.gestureMotionThreshold")</code>.
893 *
894 * @return the drag gesture motion threshold
895 * @see MouseDragGestureRecognizer
896 * @since 1.5
897 */
898 public static int getDragThreshold() {
899 int ts = ((Integer)AccessController.doPrivileged(
900 new GetIntegerAction("awt.dnd.drag.threshold", 0))).intValue();
901 if (ts > 0) {
902 return ts;
903 } else {
904 Integer td = (Integer)Toolkit.getDefaultToolkit().
905 getDesktopProperty("DnD.gestureMotionThreshold");
906 if (td != null) {
907 return td.intValue();
908 }
909 }
910 return 5;
911 }
912
913 /*
914 * fields
915 */
916
917 private transient FlavorMap flavorMap = SystemFlavorMap.getDefaultFlavorMap();
918
919 private transient DragSourceListener listener;
|
583 if (dsl != null) {
584 synchronized (this) {
585 listener = DnDEventMulticaster.remove(listener, dsl);
586 }
587 }
588 }
589
590 /**
591 * Gets all the <code>DragSourceListener</code>s
592 * registered with this <code>DragSource</code>.
593 *
594 * @return all of this <code>DragSource</code>'s
595 * <code>DragSourceListener</code>s or an empty array if no
596 * such listeners are currently registered
597 *
598 * @see #addDragSourceListener
599 * @see #removeDragSourceListener
600 * @since 1.4
601 */
602 public DragSourceListener[] getDragSourceListeners() {
603 return getListeners(DragSourceListener.class);
604 }
605
606 /**
607 * Adds the specified <code>DragSourceMotionListener</code> to this
608 * <code>DragSource</code> to receive drag motion events during drag
609 * operations intiated with this <code>DragSource</code>.
610 * If a <code>null</code> listener is specified, no action is taken and no
611 * exception is thrown.
612 *
613 * @param dsml the <code>DragSourceMotionListener</code> to add
614 *
615 * @see #removeDragSourceMotionListener
616 * @see #getDragSourceMotionListeners
617 * @since 1.4
618 */
619 public void addDragSourceMotionListener(DragSourceMotionListener dsml) {
620 if (dsml != null) {
621 synchronized (this) {
622 motionListener = DnDEventMulticaster.add(motionListener, dsml);
623 }
643 if (dsml != null) {
644 synchronized (this) {
645 motionListener = DnDEventMulticaster.remove(motionListener, dsml);
646 }
647 }
648 }
649
650 /**
651 * Gets all of the <code>DragSourceMotionListener</code>s
652 * registered with this <code>DragSource</code>.
653 *
654 * @return all of this <code>DragSource</code>'s
655 * <code>DragSourceMotionListener</code>s or an empty array if no
656 * such listeners are currently registered
657 *
658 * @see #addDragSourceMotionListener
659 * @see #removeDragSourceMotionListener
660 * @since 1.4
661 */
662 public DragSourceMotionListener[] getDragSourceMotionListeners() {
663 return getListeners(DragSourceMotionListener.class);
664 }
665
666 /**
667 * Gets all the objects currently registered as
668 * <code><em>Foo</em>Listener</code>s upon this <code>DragSource</code>.
669 * <code><em>Foo</em>Listener</code>s are registered using the
670 * <code>add<em>Foo</em>Listener</code> method.
671 *
672 * @param listenerType the type of listeners requested; this parameter
673 * should specify an interface that descends from
674 * <code>java.util.EventListener</code>
675 * @return an array of all objects registered as
676 * <code><em>Foo</em>Listener</code>s on this
677 * <code>DragSource</code>, or an empty array if no such listeners
678 * have been added
679 * @exception <code>ClassCastException</code> if <code>listenerType</code>
680 * doesn't specify a class or interface that implements
681 * <code>java.util.EventListener</code>
682 *
683 * @see #getDragSourceListeners
878 }
879 }
880
881 /**
882 * Returns the drag gesture motion threshold. The drag gesture motion threshold
883 * defines the recommended behavior for {@link MouseDragGestureRecognizer}s.
884 * <p>
885 * If the system property <code>awt.dnd.drag.threshold</code> is set to
886 * a positive integer, this method returns the value of the system property;
887 * otherwise if a pertinent desktop property is available and supported by
888 * the implementation of the Java platform, this method returns the value of
889 * that property; otherwise this method returns some default value.
890 * The pertinent desktop property can be queried using
891 * <code>java.awt.Toolkit.getDesktopProperty("DnD.gestureMotionThreshold")</code>.
892 *
893 * @return the drag gesture motion threshold
894 * @see MouseDragGestureRecognizer
895 * @since 1.5
896 */
897 public static int getDragThreshold() {
898 int ts = (AccessController.doPrivileged(
899 new GetIntegerAction("awt.dnd.drag.threshold", 0))).intValue();
900 if (ts > 0) {
901 return ts;
902 } else {
903 Integer td = (Integer)Toolkit.getDefaultToolkit().
904 getDesktopProperty("DnD.gestureMotionThreshold");
905 if (td != null) {
906 return td.intValue();
907 }
908 }
909 return 5;
910 }
911
912 /*
913 * fields
914 */
915
916 private transient FlavorMap flavorMap = SystemFlavorMap.getDefaultFlavorMap();
917
918 private transient DragSourceListener listener;
|