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