1. /*
  2. * @(#)DropTargetAdapter.java 1.7 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.dnd;
  8. /**
  9. * An abstract adapter class for receiving drop target events. The methods in
  10. * this class are empty. This class exists only as a convenience for creating
  11. * listener objects.
  12. * <p>
  13. * Extend this class to create a <code>DropTargetEvent</code> listener
  14. * and override the methods for the events of interest. (If you implement the
  15. * <code>DropTargetListener</code> interface, you have to define all of
  16. * the methods in it. This abstract class defines a null implementation for
  17. * every method except <code>drop(DropTargetDropEvent)</code>, so you only have
  18. * to define methods for events you care about.) You must provide an
  19. * implementation for at least <code>drop(DropTargetDropEvent)</code>. This
  20. * method cannot have a null implementation because its specification requires
  21. * that you either accept or reject the drop, and, if accepted, indicate
  22. * whether the drop was successful.
  23. * <p>
  24. * Create a listener object using the extended class and then register it with
  25. * a <code>DropTarget</code>. When the drag enters, moves over, or exits
  26. * the operable part of the drop site for that <code>DropTarget</code>, when
  27. * the drop action changes, and when the drop occurs, the relevant method in
  28. * the listener object is invoked, and the <code>DropTargetEvent</code> is
  29. * passed to it.
  30. * <p>
  31. * The operable part of the drop site for the <code>DropTarget</code> is
  32. * the part of the associated <code>Component</code>'s geometry that is not
  33. * obscured by an overlapping top-level window or by another
  34. * <code>Component</code> higher in the Z-order that has an associated active
  35. * <code>DropTarget</code>.
  36. * <p>
  37. * During the drag, the data associated with the current drag operation can be
  38. * retrieved by calling <code>getTransferable()</code> on
  39. * <code>DropTargetDragEvent</code> instances passed to the listener's
  40. * methods.
  41. * <p>
  42. * Note that <code>getTransferable()</code> on the
  43. * <code>DropTargetDragEvent</code> instance should only be called within the
  44. * respective listener's method and all the necessary data should be retrieved
  45. * from the returned <code>Transferable</code> before that method returns.
  46. *
  47. * @see DropTargetEvent
  48. * @see DropTargetListener
  49. *
  50. * @author David Mendenhall
  51. * @version 1.7, 12/19/03
  52. * @since 1.4
  53. */
  54. public abstract class DropTargetAdapter implements DropTargetListener {
  55. /**
  56. * Called while a drag operation is ongoing, when the mouse pointer enters
  57. * the operable part of the drop site for the <code>DropTarget</code>
  58. * registered with this listener.
  59. *
  60. * @param dtde the <code>DropTargetDragEvent</code>
  61. */
  62. public void dragEnter(DropTargetDragEvent dtde) {}
  63. /**
  64. * Called when a drag operation is ongoing, while the mouse pointer is still
  65. * over the operable part of the drop site for the <code>DropTarget</code>
  66. * registered with this listener.
  67. *
  68. * @param dtde the <code>DropTargetDragEvent</code>
  69. */
  70. public void dragOver(DropTargetDragEvent dtde) {}
  71. /**
  72. * Called if the user has modified
  73. * the current drop gesture.
  74. *
  75. * @param dtde the <code>DropTargetDragEvent</code>
  76. */
  77. public void dropActionChanged(DropTargetDragEvent dtde) {}
  78. /**
  79. * Called while a drag operation is ongoing, when the mouse pointer has
  80. * exited the operable part of the drop site for the
  81. * <code>DropTarget</code> registered with this listener.
  82. *
  83. * @param dte the <code>DropTargetEvent</code>
  84. */
  85. public void dragExit(DropTargetEvent dte) {}
  86. }