jdk/src/share/classes/java/awt/dnd/DragSource.java
author flar
Fri, 29 Apr 2011 10:58:33 -0700
changeset 9465 d336b679b605
parent 5506 202f599c92aa
child 15994 5c8a3d840366
permissions -rw-r--r--
6522514: Extending Arc2D.Double and serializing the object causes InvalidClassException Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt.dnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Cursor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.GraphicsEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.Point;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Toolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.datatransfer.FlavorMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.datatransfer.SystemFlavorMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.datatransfer.Transferable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.dnd.peer.DragSourceContextPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.util.EventListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import sun.awt.dnd.SunDragSourceContextPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import sun.security.action.GetIntegerAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * The <code>DragSource</code> is the entity responsible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * for the initiation of the Drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * and Drop operation, and may be used in a number of scenarios:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <LI>1 default instance per JVM for the lifetime of that JVM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <LI>1 instance per class of potential Drag Initiator object (e.g
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * TextField). [implementation dependent]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <LI>1 per instance of a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <code>Component</code>, or application specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * object associated with a <code>Component</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * instance in the GUI. [implementation dependent]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <LI>Some other arbitrary association. [implementation dependent]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *</UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * Once the <code>DragSource</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * obtained, a <code>DragGestureRecognizer</code> should
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * also be obtained to associate the <code>DragSource</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * with a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * The initial interpretation of the user's gesture,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * and the subsequent starting of the drag operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * are the responsibility of the implementing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <code>Component</code>, which is usually
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * implemented by a <code>DragGestureRecognizer</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * When a drag gesture occurs, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <code>DragSource</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * startDrag() method shall be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * invoked in order to cause processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * of the user's navigational
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * gestures and delivery of Drag and Drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * protocol notifications. A
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * <code>DragSource</code> shall only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * permit a single Drag and Drop operation to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * current at any one time, and shall
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * reject any further startDrag() requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * by throwing an <code>IllegalDnDOperationException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * until such time as the extant operation is complete.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * The startDrag() method invokes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * createDragSourceContext() method to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * instantiate an appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * <code>DragSourceContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * and associate the <code>DragSourceContextPeer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * with that.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * If the Drag and Drop System is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * unable to initiate a drag operation for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * some reason, the startDrag() method throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * a <code>java.awt.dnd.InvalidDnDOperationException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * to signal such a condition. Typically this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * exception is thrown when the underlying platform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * system is either not in a state to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * initiate a drag, or the parameters specified are invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * Note that during the drag, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * set of operations exposed by the source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * at the start of the drag operation may not change
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * until the operation is complete.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * The operation(s) are constant for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * duration of the operation with respect to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
public class DragSource implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    private static final long serialVersionUID = 6236096958971414066L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * load a system default cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    private static Cursor load(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            return (Cursor)Toolkit.getDefaultToolkit().getDesktopProperty(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            throw new RuntimeException("failed to load system cursor: " + name + " : " + e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * The default <code>Cursor</code> to use with a copy operation indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * that a drop is currently allowed. <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public static final Cursor DefaultCopyDrop =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        load("DnD.Cursor.CopyDrop");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * The default <code>Cursor</code> to use with a move operation indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * that a drop is currently allowed. <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    public static final Cursor DefaultMoveDrop =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        load("DnD.Cursor.MoveDrop");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * The default <code>Cursor</code> to use with a link operation indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * that a drop is currently allowed. <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public static final Cursor DefaultLinkDrop =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        load("DnD.Cursor.LinkDrop");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * The default <code>Cursor</code> to use with a copy operation indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * that a drop is currently not allowed. <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public static final Cursor DefaultCopyNoDrop =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        load("DnD.Cursor.CopyNoDrop");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * The default <code>Cursor</code> to use with a move operation indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * that a drop is currently not allowed. <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    public static final Cursor DefaultMoveNoDrop =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        load("DnD.Cursor.MoveNoDrop");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * The default <code>Cursor</code> to use with a link operation indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * that a drop is currently not allowed. <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public static final Cursor DefaultLinkNoDrop =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        load("DnD.Cursor.LinkNoDrop");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    private static final DragSource dflt =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        (GraphicsEnvironment.isHeadless()) ? null : new DragSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * Internal constants for serialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    static final String dragSourceListenerK = "dragSourceL";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    static final String dragSourceMotionListenerK = "dragSourceMotionL";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * Gets the <code>DragSource</code> object associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * the underlying platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @return the platform DragSource
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *            returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    public static DragSource getDefaultDragSource() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            throw new HeadlessException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            return dflt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * Reports
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * whether or not drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * <code>Image</code> support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * is available on the underlying platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @return if the Drag Image support is available on this platform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    public static boolean isDragImageSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        Toolkit t = Toolkit.getDefaultToolkit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        Boolean supported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            supported = (Boolean)Toolkit.getDefaultToolkit().getDesktopProperty("DnD.isDragImageSupported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            return supported.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * Creates a new <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *            returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    public DragSource() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            throw new HeadlessException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * Start a drag, given the <code>DragGestureEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * that initiated the drag, the initial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * <code>Cursor</code> to use,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * the <code>Image</code> to drag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * the offset of the <code>Image</code> origin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * from the hotspot of the <code>Cursor</code> at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * the instant of the trigger,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * the <code>Transferable</code> subject data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * of the drag, the <code>DragSourceListener</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * and the <code>FlavorMap</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * @param dragCursor     the initial {@code Cursor} for this drag operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *                       or {@code null} for the default cursor handling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *                       for more details on the cursor handling mechanism during drag and drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @param dragImage      the image to drag or {@code null}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *                       of the <code>Cursor</code> at the instant of the trigger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @param transferable   the subject data of the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @param dsl            the <code>DragSourceListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @throws java.awt.dnd.InvalidDnDOperationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     *    if the Drag and Drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     *    system is unable to initiate a drag operation, or if the user
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     *    attempts to start a drag while an existing drag operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *    is still executing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public void startDrag(DragGestureEvent   trigger,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                          Cursor             dragCursor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                          Image              dragImage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                          Point              imageOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                          Transferable       transferable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                          DragSourceListener dsl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                          FlavorMap          flavorMap) throws InvalidDnDOperationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        SunDragSourceContextPeer.setDragDropInProgress(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            if (flavorMap != null) this.flavorMap = flavorMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            DragSourceContext     dsc = createDragSourceContext(dscp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                                                                trigger,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                                                                dragCursor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                                                                dragImage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                                                                imageOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                                                                transferable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                                                                dsl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                                                                );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            if (dsc == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                throw new InvalidDnDOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        } catch (RuntimeException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            SunDragSourceContextPeer.setDragDropInProgress(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * Start a drag, given the <code>DragGestureEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * that initiated the drag, the initial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * <code>Cursor</code> to use,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * the <code>Transferable</code> subject data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * of the drag, the <code>DragSourceListener</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * and the <code>FlavorMap</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @param trigger        the <code>DragGestureEvent</code> that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * initiated the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @param dragCursor     the initial {@code Cursor} for this drag operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *                       or {@code null} for the default cursor handling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     *                       for more details on the cursor handling mechanism during drag and drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * @param transferable   the subject data of the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @param dsl            the <code>DragSourceListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @param flavorMap      the <code>FlavorMap</code> to use or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @throws java.awt.dnd.InvalidDnDOperationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     *    if the Drag and Drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *    system is unable to initiate a drag operation, or if the user
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *    attempts to start a drag while an existing drag operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *    is still executing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    public void startDrag(DragGestureEvent   trigger,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                          Cursor             dragCursor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                          Transferable       transferable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                          DragSourceListener dsl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                          FlavorMap          flavorMap) throws InvalidDnDOperationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        startDrag(trigger, dragCursor, null, null, transferable, dsl, flavorMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * Start a drag, given the <code>DragGestureEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * that initiated the drag, the initial <code>Cursor</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * to use,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * the <code>Image</code> to drag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * the offset of the <code>Image</code> origin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * from the hotspot of the <code>Cursor</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * at the instant of the trigger,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * the subject data of the drag, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * the <code>DragSourceListener</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * @param trigger           the <code>DragGestureEvent</code> that initiated the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @param dragCursor     the initial {@code Cursor} for this drag operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     *                       or {@code null} for the default cursor handling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     *                       for more details on the cursor handling mechanism during drag and drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * @param dragImage         the <code>Image</code> to drag or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @param dragOffset        the offset of the <code>Image</code> origin from the hotspot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *                          of the <code>Cursor</code> at the instant of the trigger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * @param transferable      the subject data of the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * @param dsl               the <code>DragSourceListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * @throws java.awt.dnd.InvalidDnDOperationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     *    if the Drag and Drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     *    system is unable to initiate a drag operation, or if the user
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *    attempts to start a drag while an existing drag operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     *    is still executing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    public void startDrag(DragGestureEvent   trigger,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                          Cursor             dragCursor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                          Image              dragImage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                          Point              dragOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                          Transferable       transferable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                          DragSourceListener dsl) throws InvalidDnDOperationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        startDrag(trigger, dragCursor, dragImage, dragOffset, transferable, dsl, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * Start a drag, given the <code>DragGestureEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * that initiated the drag, the initial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * <code>Cursor</code> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * use,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * the <code>Transferable</code> subject data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * of the drag, and the <code>DragSourceListener</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * @param trigger           the <code>DragGestureEvent</code> that initiated the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * @param dragCursor     the initial {@code Cursor} for this drag operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     *                       or {@code null} for the default cursor handling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a> class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     *                       for more details on the cursor handling mechanism during drag and drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @param transferable      the subject data of the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @param dsl               the <code>DragSourceListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @throws java.awt.dnd.InvalidDnDOperationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     *    if the Drag and Drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     *    system is unable to initiate a drag operation, or if the user
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *    attempts to start a drag while an existing drag operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     *    is still executing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    public void startDrag(DragGestureEvent   trigger,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                          Cursor             dragCursor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                          Transferable       transferable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                          DragSourceListener dsl) throws InvalidDnDOperationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        startDrag(trigger, dragCursor, null, null, transferable, dsl, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * Creates the {@code DragSourceContext} to handle the current drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * To incorporate a new <code>DragSourceContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * subclass, subclass <code>DragSource</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * override this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * If <code>dragImage</code> is <code>null</code>, no image is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * to represent the drag over feedback for this drag operation, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * <code>NullPointerException</code> is not thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * If <code>dsl</code> is <code>null</code>, no drag source listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * is registered with the created <code>DragSourceContext</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * but <code>NullPointerException</code> is not thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @param dscp          The <code>DragSourceContextPeer</code> for this drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * @param dgl           The <code>DragGestureEvent</code> that triggered the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     *                      drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * @param dragCursor     The initial {@code Cursor} for this drag operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     *                       or {@code null} for the default cursor handling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a> class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     *                       for more details on the cursor handling mechanism during drag and drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * @param dragImage     The <code>Image</code> to drag or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * @param imageOffset   The offset of the <code>Image</code> origin from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *                      hotspot of the cursor at the instant of the trigger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * @param t             The subject data of the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @param dsl           The <code>DragSourceListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * @return the <code>DragSourceContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * @throws NullPointerException if <code>dscp</code> is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * @throws NullPointerException if <code>dgl</code> is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * @throws NullPointerException if <code>dragImage</code> is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     *    <code>null</code> and <code>imageOffset</code> is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @throws NullPointerException if <code>t</code> is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @throws IllegalArgumentException if the <code>Component</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     *         associated with the trigger event is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * @throws IllegalArgumentException if the <code>DragSource</code> for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *         trigger event is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @throws IllegalArgumentException if the drag action for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *         trigger event is <code>DnDConstants.ACTION_NONE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * @throws IllegalArgumentException if the source actions for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     *         <code>DragGestureRecognizer</code> associated with the trigger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *         event are equal to <code>DnDConstants.ACTION_NONE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    protected DragSourceContext createDragSourceContext(DragSourceContextPeer dscp, DragGestureEvent dgl, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable t, DragSourceListener dsl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        return new DragSourceContext(dscp, dgl, dragCursor, dragImage, imageOffset, t, dsl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * This method returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * <code>FlavorMap</code> for this <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * @return the <code>FlavorMap</code> for this <code>DragSource</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    public FlavorMap getFlavorMap() { return flavorMap; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * Creates a new <code>DragGestureRecognizer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * that implements the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * abstract subclass of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * <code>DragGestureRecognizer</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * sets the specified <code>Component</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * and <code>DragGestureListener</code> on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * the newly created object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * @param recognizerAbstractClass the requested abstract type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @param actions                 the permitted source drag actions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @param c                       the <code>Component</code> target
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @param dgl        the <code>DragGestureListener</code> to notify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @return the new <code>DragGestureRecognizer</code> or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     *    if the <code>Toolkit.createDragGestureRecognizer</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     *    has no implementation available for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     *    the requested <code>DragGestureRecognizer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     *    subclass and returns <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    public <T extends DragGestureRecognizer> T
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        createDragGestureRecognizer(Class<T> recognizerAbstractClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                                    Component c, int actions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                                    DragGestureListener dgl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        return Toolkit.getDefaultToolkit().createDragGestureRecognizer(recognizerAbstractClass, this, c, actions, dgl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * Creates a new <code>DragGestureRecognizer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * that implements the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * abstract subclass of <code>DragGestureRecognizer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * for this <code>DragSource</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * and sets the specified <code>Component</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * and <code>DragGestureListener</code> on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * newly created object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * For this <code>DragSource</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * the default is <code>MouseDragGestureRecognizer</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * @param c       the <code>Component</code> target for the recognizer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * @param actions the permitted source actions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @param dgl     the <code>DragGestureListener</code> to notify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * @return the new <code>DragGestureRecognizer</code> or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     *    if the <code>Toolkit.createDragGestureRecognizer</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *    has no implementation available for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     *    the requested <code>DragGestureRecognizer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     *    subclass and returns <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    public DragGestureRecognizer createDefaultDragGestureRecognizer(Component c, int actions, DragGestureListener dgl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        return Toolkit.getDefaultToolkit().createDragGestureRecognizer(MouseDragGestureRecognizer.class, this, c, actions, dgl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * Adds the specified <code>DragSourceListener</code> to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * <code>DragSource</code> to receive drag source events during drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * operations intiated with this <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * If a <code>null</code> listener is specified, no action is taken and no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * exception is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * @param dsl the <code>DragSourceListener</code> to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * @see      #removeDragSourceListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * @see      #getDragSourceListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    public void addDragSourceListener(DragSourceListener dsl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        if (dsl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                listener = DnDEventMulticaster.add(listener, dsl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * Removes the specified <code>DragSourceListener</code> from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * If a <code>null</code> listener is specified, no action is taken and no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * exception is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * If the listener specified by the argument was not previously added to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * this <code>DragSource</code>, no action is taken and no exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @param dsl the <code>DragSourceListener</code> to remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * @see      #addDragSourceListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * @see      #getDragSourceListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    public void removeDragSourceListener(DragSourceListener dsl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        if (dsl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                listener = DnDEventMulticaster.remove(listener, dsl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * Gets all the <code>DragSourceListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * registered with this <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * @return all of this <code>DragSource</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     *         <code>DragSourceListener</code>s or an empty array if no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     *         such listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * @see      #addDragSourceListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * @see      #removeDragSourceListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * @since    1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    public DragSourceListener[] getDragSourceListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        return (DragSourceListener[])getListeners(DragSourceListener.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * Adds the specified <code>DragSourceMotionListener</code> to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * <code>DragSource</code> to receive drag motion events during drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * operations intiated with this <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * If a <code>null</code> listener is specified, no action is taken and no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     * exception is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * @param dsml the <code>DragSourceMotionListener</code> to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * @see      #removeDragSourceMotionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * @see      #getDragSourceMotionListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    public void addDragSourceMotionListener(DragSourceMotionListener dsml) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        if (dsml != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                motionListener = DnDEventMulticaster.add(motionListener, dsml);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * Removes the specified <code>DragSourceMotionListener</code> from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * If a <code>null</code> listener is specified, no action is taken and no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * exception is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * If the listener specified by the argument was not previously added to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * this <code>DragSource</code>, no action is taken and no exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * @param dsml the <code>DragSourceMotionListener</code> to remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * @see      #addDragSourceMotionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * @see      #getDragSourceMotionListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    public void removeDragSourceMotionListener(DragSourceMotionListener dsml) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        if (dsml != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
                motionListener = DnDEventMulticaster.remove(motionListener, dsml);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * Gets all of the  <code>DragSourceMotionListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * registered with this <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * @return all of this <code>DragSource</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     *         <code>DragSourceMotionListener</code>s or an empty array if no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     *         such listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * @see      #addDragSourceMotionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * @see      #removeDragSourceMotionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * @since    1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    public DragSourceMotionListener[] getDragSourceMotionListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        return (DragSourceMotionListener[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            getListeners(DragSourceMotionListener.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * Gets all the objects currently registered as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * <code><em>Foo</em>Listener</code>s upon this <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * <code><em>Foo</em>Listener</code>s are registered using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * <code>add<em>Foo</em>Listener</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * @param listenerType the type of listeners requested; this parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     *          should specify an interface that descends from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     *          <code>java.util.EventListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * @return an array of all objects registered as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     *          <code><em>Foo</em>Listener</code>s on this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     *          <code>DragSource</code>, or an empty array if no such listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     *          have been added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * @exception <code>ClassCastException</code> if <code>listenerType</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     *          doesn't specify a class or interface that implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     *          <code>java.util.EventListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * @see #getDragSourceListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * @see #getDragSourceMotionListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        EventListener l = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        if (listenerType == DragSourceListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
            l = listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        } else if (listenerType == DragSourceMotionListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            l = motionListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        return DnDEventMulticaster.getListeners(l, listenerType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * This method calls <code>dragEnter</code> on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * <code>DragSourceListener</code>s registered with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * <code>DragSource</code>, and passes them the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * <code>DragSourceDragEvent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * @param dsde the <code>DragSourceDragEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    void processDragEnter(DragSourceDragEvent dsde) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        DragSourceListener dsl = listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        if (dsl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            dsl.dragEnter(dsde);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * This method calls <code>dragOver</code> on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * <code>DragSourceListener</code>s registered with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * <code>DragSource</code>, and passes them the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * <code>DragSourceDragEvent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * @param dsde the <code>DragSourceDragEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    void processDragOver(DragSourceDragEvent dsde) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        DragSourceListener dsl = listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        if (dsl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
            dsl.dragOver(dsde);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * This method calls <code>dropActionChanged</code> on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * <code>DragSourceListener</code>s registered with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * <code>DragSource</code>, and passes them the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * <code>DragSourceDragEvent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     * @param dsde the <code>DragSourceDragEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    void processDropActionChanged(DragSourceDragEvent dsde) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        DragSourceListener dsl = listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        if (dsl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            dsl.dropActionChanged(dsde);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * This method calls <code>dragExit</code> on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * <code>DragSourceListener</code>s registered with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * <code>DragSource</code>, and passes them the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * <code>DragSourceEvent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     * @param dse the <code>DragSourceEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    void processDragExit(DragSourceEvent dse) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        DragSourceListener dsl = listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        if (dsl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
            dsl.dragExit(dse);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     * This method calls <code>dragDropEnd</code> on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     * <code>DragSourceListener</code>s registered with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     * <code>DragSource</code>, and passes them the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     * <code>DragSourceDropEvent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * @param dsde the <code>DragSourceEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    void processDragDropEnd(DragSourceDropEvent dsde) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        DragSourceListener dsl = listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        if (dsl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            dsl.dragDropEnd(dsde);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * This method calls <code>dragMouseMoved</code> on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * <code>DragSourceMotionListener</code>s registered with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * <code>DragSource</code>, and passes them the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * <code>DragSourceDragEvent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * @param dsde the <code>DragSourceEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    void processDragMouseMoved(DragSourceDragEvent dsde) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        DragSourceMotionListener dsml = motionListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        if (dsml != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
            dsml.dragMouseMoved(dsde);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * Serializes this <code>DragSource</code>. This method first performs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * default serialization. Next, it writes out this object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * <code>FlavorMap</code> if and only if it can be serialized. If not,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     * <code>null</code> is written instead. Next, it writes out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * <code>Serializable</code> listeners registered with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     * object. Listeners are written in a <code>null</code>-terminated sequence
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * of 0 or more pairs. The pair consists of a <code>String</code> and an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     * <code>Object</code>; the <code>String</code> indicates the type of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * <code>Object</code> and is one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * <li><code>dragSourceListenerK</code> indicating a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     *     <code>DragSourceListener</code> object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * <li><code>dragSourceMotionListenerK</code> indicating a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     *     <code>DragSourceMotionListener</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * @serialData Either a <code>FlavorMap</code> instance, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     *      <code>null</code>, followed by a <code>null</code>-terminated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     *      sequence of 0 or more pairs; the pair consists of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     *      <code>String</code> and an <code>Object</code>; the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     *      <code>String</code> indicates the type of the <code>Object</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     *      and is one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     *      <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     *      <li><code>dragSourceListenerK</code> indicating a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     *          <code>DragSourceListener</code> object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     *      <li><code>dragSourceMotionListenerK</code> indicating a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     *          <code>DragSourceMotionListener</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     *      </ul>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        s.writeObject(SerializationTester.test(flavorMap) ? flavorMap : null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        DnDEventMulticaster.save(s, dragSourceListenerK, listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        DnDEventMulticaster.save(s, dragSourceMotionListenerK, motionListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        s.writeObject(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * Deserializes this <code>DragSource</code>. This method first performs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * default deserialization. Next, this object's <code>FlavorMap</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * deserialized by using the next object in the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * If the resulting <code>FlavorMap</code> is <code>null</code>, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * object's <code>FlavorMap</code> is set to the default FlavorMap for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     * this thread's <code>ClassLoader</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * Next, this object's listeners are deserialized by reading a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     * <code>null</code>-terminated sequence of 0 or more key/value pairs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * from the stream:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * <li>If a key object is a <code>String</code> equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * deserialized using the corresponding value object and added to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     * <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * <li>If a key object is a <code>String</code> equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * <code>dragSourceMotionListenerK</code>, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     * <code>DragSourceMotionListener</code> is deserialized using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     * corresponding value object and added to this <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     * <li>Otherwise, the key/value pair is skipped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
      throws ClassNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        // 'flavorMap' was written explicitly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        flavorMap = (FlavorMap)s.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        // Implementation assumes 'flavorMap' is never null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        if (flavorMap == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
            flavorMap = SystemFlavorMap.getDefaultFlavorMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        Object keyOrNull;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        while (null != (keyOrNull = s.readObject())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
            String key = ((String)keyOrNull).intern();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
            if (dragSourceListenerK == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                addDragSourceListener((DragSourceListener)(s.readObject()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
            } else if (dragSourceMotionListenerK == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
                addDragSourceMotionListener(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
                    (DragSourceMotionListener)(s.readObject()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
                // skip value for unrecognized key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                s.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
     * Returns the drag gesture motion threshold. The drag gesture motion threshold
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     * defines the recommended behavior for {@link MouseDragGestureRecognizer}s.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     * If the system property <code>awt.dnd.drag.threshold</code> is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
     * a positive integer, this method returns the value of the system property;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
     * otherwise if a pertinent desktop property is available and supported by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
     * the implementation of the Java platform, this method returns the value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
     * that property; otherwise this method returns some default value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     * The pertinent desktop property can be queried using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     * <code>java.awt.Toolkit.getDesktopProperty("DnD.gestureMotionThreshold")</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * @return the drag gesture motion threshold
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     * @see MouseDragGestureRecognizer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    public static int getDragThreshold() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
        int ts = ((Integer)AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                new GetIntegerAction("awt.dnd.drag.threshold", 0))).intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        if (ts > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            return ts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            Integer td = (Integer)Toolkit.getDefaultToolkit().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
                    getDesktopProperty("DnD.gestureMotionThreshold");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
            if (td != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                return td.intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
        return 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     * fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    private transient FlavorMap flavorMap = SystemFlavorMap.getDefaultFlavorMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
    private transient DragSourceListener listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
    private transient DragSourceMotionListener motionListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
}