Showing the changes to java/pkg/java/awt/dnd/DragSourceEvent.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,185 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. | ||
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| 4 | * | ||
| 5 | * This code is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms of the GNU General Public License version 2 only, as | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 10 | * | ||
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 14 | * version 2 for more details (a copy is included in the LICENSE file that | ||
| 15 | * accompanied this code). | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License version | ||
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, | ||
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | * | ||
| 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| 22 | * or visit www.oracle.com if you need additional information or have any | ||
| 23 | * questions. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package java.awt.dnd; | ||
| 27 | |||
| 28 | import java.awt.Point; | ||
| 29 | |||
| 30 | import java.util.EventObject; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * This class is the base class for | ||
| 34 | * <code>DragSourceDragEvent</code> and | ||
| 35 | * <code>DragSourceDropEvent</code>. | ||
| 36 | * <p> | ||
| 37 | * <code>DragSourceEvent</code>s are generated whenever the drag enters, moves | ||
| 38 | * over, or exits a drop site, when the drop action changes, and when the drag | ||
| 39 | * ends. The location for the generated <code>DragSourceEvent</code> specifies | ||
| 40 | * the mouse cursor location in screen coordinates at the moment this event | ||
| 41 | * occured. | ||
| 42 | * <p> | ||
| 43 | * In a multi-screen environment without a virtual device, the cursor location is | ||
| 44 | * specified in the coordinate system of the <i>initiator</i> | ||
| 45 | * <code>GraphicsConfiguration</code>. The <i>initiator</i> | ||
| 46 | * <code>GraphicsConfiguration</code> is the <code>GraphicsConfiguration</code> | ||
| 47 | * of the <code>Component</code> on which the drag gesture for the current drag | ||
| 48 | * operation was recognized. If the cursor location is outside the bounds of | ||
| 49 | * the initiator <code>GraphicsConfiguration</code>, the reported coordinates are | ||
| 50 | * clipped to fit within the bounds of that <code>GraphicsConfiguration</code>. | ||
| 51 | * <p> | ||
| 52 | * In a multi-screen environment with a virtual device, the location is specified | ||
| 53 | * in the corresponding virtual coordinate system. If the cursor location is | ||
| 54 | * outside the bounds of the virtual device the reported coordinates are | ||
| 55 | * clipped to fit within the bounds of the virtual device. | ||
| 56 | * | ||
| 57 | * @since 1.2 | ||
| 58 | */ | ||
| 59 | |||
| 60 | public class DragSourceEvent extends EventObject { | ||
| 61 | |||
| 62 | private static final long serialVersionUID = -763287114604032641L; | ||
| 63 | |||
| 64 | /** | ||
| 65 | * The <code>boolean</code> indicating whether the cursor location | ||
| 66 | * is specified for this event. | ||
| 67 | * | ||
| 68 | * @serial | ||
| 69 | */ | ||
| 70 | private final boolean locationSpecified; | ||
| 71 | |||
| 72 | /** | ||
| 73 | * The horizontal coordinate for the cursor location at the moment this | ||
| 74 | * event occured if the cursor location is specified for this event; | ||
| 75 | * otherwise zero. | ||
| 76 | * | ||
| 77 | * @serial | ||
| 78 | */ | ||
| 79 | private final int x; | ||
| 80 | |||
| 81 | /** | ||
| 82 | * The vertical coordinate for the cursor location at the moment this event | ||
| 83 | * occured if the cursor location is specified for this event; | ||
| 84 | * otherwise zero. | ||
| 85 | * | ||
| 86 | * @serial | ||
| 87 | */ | ||
| 88 | private final int y; | ||
| 89 | |||
| 90 | /** | ||
| 91 | * Construct a <code>DragSourceEvent</code> | ||
| 92 | * given a specified <code>DragSourceContext</code>. | ||
| 93 | * The coordinates for this <code>DragSourceEvent</code> | ||
| 94 | * are not specified, so <code>getLocation</code> will return | ||
| 95 | * <code>null</code> for this event. | ||
| 96 | * | ||
| 97 | * @param dsc the <code>DragSourceContext</code> | ||
| 98 | * | ||
| 99 | * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>. | ||
| 100 | * | ||
| 101 | * @see #getLocation | ||
| 102 | */ | ||
| 103 | |||
| 104 | public DragSourceEvent(DragSourceContext dsc) { | ||
| 105 | super(dsc); | ||
| 106 | locationSpecified = false; | ||
| 107 | this.x = 0; | ||
| 108 | this.y = 0; | ||
| 109 | } | ||
| 110 | |||
| 111 | /** | ||
| 112 | * Construct a <code>DragSourceEvent</code> given a specified | ||
| 113 | * <code>DragSourceContext</code>, and coordinates of the cursor | ||
| 114 | * location. | ||
| 115 | * | ||
| 116 | * @param dsc the <code>DragSourceContext</code> | ||
| 117 | * @param x the horizontal coordinate for the cursor location | ||
| 118 | * @param y the vertical coordinate for the cursor location | ||
| 119 | * | ||
| 120 | * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>. | ||
| 121 | * | ||
| 122 | * @since 1.4 | ||
| 123 | */ | ||
| 124 | public DragSourceEvent(DragSourceContext dsc, int x, int y) { | ||
| 125 | super(dsc); | ||
| 126 | locationSpecified = true; | ||
| 127 | this.x = x; | ||
| 128 | this.y = y; | ||
| 129 | } | ||
| 130 | |||
| 131 | /** | ||
| 132 | * This method returns the <code>DragSourceContext</code> that | ||
| 133 | * originated the event. | ||
| 134 | * <P> | ||
| 135 | * @return the <code>DragSourceContext</code> that originated the event | ||
| 136 | */ | ||
| 137 | |||
| 138 | public DragSourceContext getDragSourceContext() { | ||
| 139 | return (DragSourceContext)getSource(); | ||
| 140 | } | ||
| 141 | |||
| 142 | /** | ||
| 143 | * This method returns a <code>Point</code> indicating the cursor | ||
| 144 | * location in screen coordinates at the moment this event occured, or | ||
| 145 | * <code>null</code> if the cursor location is not specified for this | ||
| 146 | * event. | ||
| 147 | * | ||
| 148 | * @return the <code>Point</code> indicating the cursor location | ||
| 149 | * or <code>null</code> if the cursor location is not specified | ||
| 150 | * @since 1.4 | ||
| 151 | */ | ||
| 152 | public Point getLocation() { | ||
| 153 | if (locationSpecified) { | ||
| 154 | return new Point(x, y); | ||
| 155 | } else { | ||
| 156 | return null; | ||
| 157 | } | ||
| 158 | } | ||
| 159 | |||
| 160 | /** | ||
| 161 | * This method returns the horizontal coordinate of the cursor location in | ||
| 162 | * screen coordinates at the moment this event occured, or zero if the | ||
| 163 | * cursor location is not specified for this event. | ||
| 164 | * | ||
| 165 | * @return an integer indicating the horizontal coordinate of the cursor | ||
| 166 | * location or zero if the cursor location is not specified | ||
| 167 | * @since 1.4 | ||
| 168 | */ | ||
| 169 | public int getX() { | ||
| 170 | return x; | ||
| 171 | } | ||
| 172 | |||
| 173 | /** | ||
| 174 | * This method returns the vertical coordinate of the cursor location in | ||
| 175 | * screen coordinates at the moment this event occured, or zero if the | ||
| 176 | * cursor location is not specified for this event. | ||
| 177 | * | ||
| 178 | * @return an integer indicating the vertical coordinate of the cursor | ||
| 179 | * location or zero if the cursor location is not specified | ||
| 180 | * @since 1.4 | ||
| 181 | */ | ||
| 182 | public int getY() { | ||
| 183 | return y; | ||
| 184 | } | ||
| 185 | } | ||