1. /*
  2. * @(#)DragSourceAdapter.java 1.6 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 drag source 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>DragSourceEvent</code> listener
  14. * and override the methods for the events of interest. (If you implement the
  15. * <code>DragSourceListener</code> interface, you have to define all of
  16. * the methods in it. This abstract class defines null methods for them
  17. * all, so you only have to define methods for events you care about.)
  18. * <p>
  19. * Create a listener object using the extended class and then register it with
  20. * a <code>DragSource</code>. When the drag enters, moves over, or exits
  21. * a drop site, when the drop action changes, and when the drag ends, the
  22. * relevant method in the listener object is invoked, and the
  23. * <code>DragSourceEvent</code> is passed to it.
  24. * <p>
  25. * The drop site is <i>associated with the previous <code>dragEnter()</code>
  26. * invocation</i> if the latest invocation of <code>dragEnter()</code> on this
  27. * adapter corresponds to that drop site and is not followed by a
  28. * <code>dragExit()</code> invocation on this adapter.
  29. *
  30. * @see DragSourceEvent
  31. * @see DragSourceListener
  32. * @see DragSourceMotionListener
  33. *
  34. * @author David Mendenhall
  35. * @version 1.6, 12/19/03
  36. * @since 1.4
  37. */
  38. public abstract class DragSourceAdapter
  39. implements DragSourceListener, DragSourceMotionListener {
  40. /**
  41. * Called as the cursor's hotspot enters a platform-dependent drop site.
  42. * This method is invoked when all the following conditions are true:
  43. * <UL>
  44. * <LI>The cursor's hotspot enters the operable part of
  45. * a platform-dependent drop site.
  46. * <LI>The drop site is active.
  47. * <LI>The drop site accepts the drag.
  48. * </UL>
  49. *
  50. * @param dsde the <code>DragSourceDragEvent</code>
  51. */
  52. public void dragEnter(DragSourceDragEvent dsde) {}
  53. /**
  54. * Called as the cursor's hotspot moves over a platform-dependent drop site.
  55. * This method is invoked when all the following conditions are true:
  56. * <UL>
  57. * <LI>The cursor's hotspot has moved, but still intersects the
  58. * operable part of the drop site associated with the previous
  59. * dragEnter() invocation.
  60. * <LI>The drop site is still active.
  61. * <LI>The drop site accepts the drag.
  62. * </UL>
  63. *
  64. * @param dsde the <code>DragSourceDragEvent</code>
  65. */
  66. public void dragOver(DragSourceDragEvent dsde) {}
  67. /**
  68. * Called whenever the mouse is moved during a drag operation.
  69. *
  70. * @param dsde the <code>DragSourceDragEvent</code>
  71. */
  72. public void dragMouseMoved(DragSourceDragEvent dsde) {}
  73. /**
  74. * Called when the user has modified the drop gesture.
  75. * This method is invoked when the state of the input
  76. * device(s) that the user is interacting with changes.
  77. * Such devices are typically the mouse buttons or keyboard
  78. * modifiers that the user is interacting with.
  79. *
  80. * @param dsde the <code>DragSourceDragEvent</code>
  81. */
  82. public void dropActionChanged(DragSourceDragEvent dsde) {}
  83. /**
  84. * Called as the cursor's hotspot exits a platform-dependent drop site.
  85. * This method is invoked when any of the following conditions are true:
  86. * <UL>
  87. * <LI>The cursor's hotspot no longer intersects the operable part
  88. * of the drop site associated with the previous dragEnter() invocation.
  89. * </UL>
  90. * OR
  91. * <UL>
  92. * <LI>The drop site associated with the previous dragEnter() invocation
  93. * is no longer active.
  94. * </UL>
  95. * OR
  96. * <UL>
  97. * <LI> The drop site associated with the previous dragEnter() invocation
  98. * has rejected the drag.
  99. * </UL>
  100. *
  101. * @param dse the <code>DragSourceEvent</code>
  102. */
  103. public void dragExit(DragSourceEvent dse) {}
  104. /**
  105. * This method is invoked to signify that the Drag and Drop
  106. * operation is complete. The getDropSuccess() method of
  107. * the <code>DragSourceDropEvent</code> can be used to
  108. * determine the termination state. The getDropAction() method
  109. * returns the operation that the drop site selected
  110. * to apply to the Drop operation. Once this method is complete, the
  111. * current <code>DragSourceContext</code> and
  112. * associated resources become invalid.
  113. *
  114. * @param dsde the <code>DragSourceDropEvent</code>
  115. */
  116. public void dragDropEnd(DragSourceDropEvent dsde) {}
  117. }