1 /* 2 * Copyright (c) 2001, 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 /** 29 * An abstract adapter class for receiving drop target events. The methods in 30 * this class are empty. This class exists only as a convenience for creating 31 * listener objects. 32 * <p> 33 * Extend this class to create a {@code DropTargetEvent} listener 34 * and override the methods for the events of interest. (If you implement the 35 * {@code DropTargetListener} interface, you have to define all of 36 * the methods in it. This abstract class defines a null implementation for 37 * every method except {@code drop(DropTargetDropEvent)}, so you only have 38 * to define methods for events you care about.) You must provide an 39 * implementation for at least {@code drop(DropTargetDropEvent)}. This 40 * method cannot have a null implementation because its specification requires 41 * that you either accept or reject the drop, and, if accepted, indicate 42 * whether the drop was successful. 43 * <p> 44 * Create a listener object using the extended class and then register it with 45 * a {@code DropTarget}. When the drag enters, moves over, or exits 46 * the operable part of the drop site for that {@code DropTarget}, when 47 * the drop action changes, and when the drop occurs, the relevant method in 48 * the listener object is invoked, and the {@code DropTargetEvent} is 49 * passed to it. 50 * <p> 51 * The operable part of the drop site for the {@code DropTarget} is 52 * the part of the associated {@code Component}'s geometry that is not 53 * obscured by an overlapping top-level window or by another 54 * {@code Component} higher in the Z-order that has an associated active 55 * {@code DropTarget}. 56 * <p> 57 * During the drag, the data associated with the current drag operation can be 58 * retrieved by calling {@code getTransferable()} on 59 * {@code DropTargetDragEvent} instances passed to the listener's 60 * methods. 61 * <p> 62 * Note that {@code getTransferable()} on the 63 * {@code DropTargetDragEvent} instance should only be called within the 64 * respective listener's method and all the necessary data should be retrieved 65 * from the returned {@code Transferable} before that method returns. 66 * 67 * @see DropTargetEvent 68 * @see DropTargetListener 69 * 70 * @author David Mendenhall 71 * @since 1.4 72 */ 73 public abstract class DropTargetAdapter implements DropTargetListener { 74 75 /** 76 * Called while a drag operation is ongoing, when the mouse pointer enters 77 * the operable part of the drop site for the {@code DropTarget} 78 * registered with this listener. 79 * 80 * @param dtde the {@code DropTargetDragEvent} 81 */ 82 public void dragEnter(DropTargetDragEvent dtde) {} 83 84 /** 85 * Called when a drag operation is ongoing, while the mouse pointer is still 86 * over the operable part of the drop site for the {@code DropTarget} 87 * registered with this listener. 88 * 89 * @param dtde the {@code DropTargetDragEvent} 90 */ 91 public void dragOver(DropTargetDragEvent dtde) {} 92 93 /** 94 * Called if the user has modified 95 * the current drop gesture. 96 * 97 * @param dtde the {@code DropTargetDragEvent} 98 */ 99 public void dropActionChanged(DropTargetDragEvent dtde) {} 100 101 /** 102 * Called while a drag operation is ongoing, when the mouse pointer has 103 * exited the operable part of the drop site for the 104 * {@code DropTarget} registered with this listener. 105 * 106 * @param dte the {@code DropTargetEvent} 107 */ 108 public void dragExit(DropTargetEvent dte) {} 109 }