jdk/src/share/classes/java/awt/dnd/DragSourceDropEvent.java
author flar
Fri, 29 Apr 2011 10:58:33 -0700
changeset 9465 d336b679b605
parent 5506 202f599c92aa
child 20156 e19f062edcfe
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, 2003, 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
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * The <code>DragSourceDropEvent</code> is delivered
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * from the <code>DragSourceContextPeer</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * via the <code>DragSourceContext</code>, to the <code>dragDropEnd</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * method of <code>DragSourceListener</code>s registered with that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <code>DragSourceContext</code> and with its associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <code>DragSource</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * It contains sufficient information for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * originator of the operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * to provide appropriate feedback to the end user
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * when the operation completes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
public class DragSourceDropEvent extends DragSourceEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private static final long serialVersionUID = -5571321229470821891L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * Construct a <code>DragSourceDropEvent</code> for a drop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * given the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * <code>DragSourceContext</code>, the drop action,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * and a <code>boolean</code> indicating if the drop was successful.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * The coordinates for this <code>DragSourceDropEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * are not specified, so <code>getLocation</code> will return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * <code>null</code> for this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * The argument <code>action</code> should be one of <code>DnDConstants</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * that represents a single action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * This constructor does not throw any exception for invalid <code>action</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @param dsc the <code>DragSourceContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * associated with this <code>DragSourceDropEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @param action the drop action
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param success a boolean indicating if the drop was successful
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @see DragSourceEvent#getLocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public DragSourceDropEvent(DragSourceContext dsc, int action, boolean success) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        super(dsc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        dropSuccess = success;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        dropAction  = action;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * Construct a <code>DragSourceDropEvent</code> for a drop, given the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * <code>DragSourceContext</code>, the drop action, a <code>boolean</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * indicating if the drop was successful, and coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * The argument <code>action</code> should be one of <code>DnDConstants</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * that represents a single action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * This constructor does not throw any exception for invalid <code>action</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @param dsc the <code>DragSourceContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * associated with this <code>DragSourceDropEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param action the drop action
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @param success a boolean indicating if the drop was successful
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @param x   the horizontal coordinate for the cursor location
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param y   the vertical coordinate for the cursor location
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public DragSourceDropEvent(DragSourceContext dsc, int action,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                               boolean success, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        super(dsc, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        dropSuccess = success;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        dropAction  = action;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Construct a <code>DragSourceDropEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * for a drag that does not result in a drop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * The coordinates for this <code>DragSourceDropEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * are not specified, so <code>getLocation</code> will return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * <code>null</code> for this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param dsc the <code>DragSourceContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @see DragSourceEvent#getLocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public DragSourceDropEvent(DragSourceContext dsc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        super(dsc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        dropSuccess = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * This method returns a <code>boolean</code> indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * if the drop was successful.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @return <code>true</code> if the drop target accepted the drop and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *         successfully performed a drop action;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *         <code>false</code> if the drop target rejected the drop or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *         if the drop target accepted the drop, but failed to perform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *         a drop action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public boolean getDropSuccess() { return dropSuccess; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * This method returns an <code>int</code> representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * the action performed by the target on the subject of the drop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @return the action performed by the target on the subject of the drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *         if the drop target accepted the drop and the target drop action
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     *         is supported by the drag source; otherwise,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *         <code>DnDConstants.ACTION_NONE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public int getDropAction() { return dropAction; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * <code>true</code> if the drop was successful.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    private boolean dropSuccess;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * The drop action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    private int     dropAction   = DnDConstants.ACTION_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
}