1. /*
  2. * @(#)DragSourceListener.java 1.12 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.dnd;
  8. import java.util.EventListener;
  9. import java.awt.dnd.DragSourceDragEvent;
  10. import java.awt.dnd.DragSourceDropEvent;
  11. /**
  12. * The <code>DragSourceListener</code> defines the
  13. * event interface for originators of
  14. * Drag and Drop operations to track the state of the user's gesture, and to
  15. * provide appropriate "drag over"
  16. * feedback to the user throughout the
  17. * Drag and Drop operation.
  18. *
  19. * @version 1.12
  20. * @since JDK1.2
  21. */
  22. public interface DragSourceListener extends EventListener {
  23. /**
  24. * Called as the hotspot enters a platform dependent drop site.
  25. * This method is invoked when the following conditions are true:
  26. * <UL>
  27. * <LI>The logical cursor's hotspot initially intersects
  28. * a GUI <code>Component</code>'s visible geometry.
  29. * <LI>That <code>Component</code> has an active
  30. * <code>DropTarget</code> associated with it.
  31. * <LI>The <code>DropTarget</code>'s registered
  32. * <code>DropTargetListener</code> dragEnter() method is invoked and
  33. * returns successfully.
  34. * <LI>The registered <code>DropTargetListener</code> invokes
  35. * the <code>DropTargetDragEvent</code>'s acceptDrag() method to
  36. * accept the drag based upon interrogation of the source's
  37. * potential drop action(s) and available data types
  38. * (<code>DataFlavor</code>s).
  39. * </UL>
  40. *<P>
  41. *@param dsde the <code>DragSourceDragEvent</code>
  42. */
  43. void dragEnter(DragSourceDragEvent dsde);
  44. /**
  45. * Called as the hotspot moves over a platform dependent drop site.
  46. * This method is invoked when the following conditions
  47. * are true:
  48. *<UL>
  49. *<LI>The cursor's logical hotspot has moved but still
  50. * intersects the visible geometry of the <code>Component</code>
  51. * associated with the previous dragEnter() invocation.
  52. * <LI>That <code>Component</code> still has a
  53. * <code>DropTarget</code> associated with it.
  54. * <LI>That <code>DropTarget</code> is still active.
  55. * <LI>The <code>DropTarget</code>'s registered
  56. * <code>DropTargetListener</code> dragOver() method
  57. * is invoked and returns successfully.
  58. * <LI>The <code>DropTarget</code> does not reject
  59. * the drag via rejectDrag()
  60. * </UL>
  61. * <P>
  62. * @param dsde the <code>DragSourceDragEvent</code>
  63. */
  64. void dragOver(DragSourceDragEvent dsde);
  65. /**
  66. * Called when the user has modified the drop gesture.
  67. * This method is invoked when the state of the input
  68. * device(s) that the user is interacting with changes.
  69. * Such devices are typically the mouse buttons or keyboard
  70. * modifiers that the user is interacting with.
  71. * <P>
  72. * @param dsde the <code>DragSourceDragEvent</code>
  73. */
  74. void dropActionChanged(DragSourceDragEvent dsde);
  75. /**
  76. * Called as the hotspot exits a platform dependent drop site.
  77. * This method is invoked when the following conditions
  78. * are true:
  79. * <UL>
  80. * <LI>The cursor's logical hotspot no longer
  81. * intersects the visible geometry of the <code>Component</code>
  82. * associated with the previous dragEnter() invocation.
  83. * </UL>
  84. * OR
  85. * <UL>
  86. * <LI>The <code>Component</code> that the logical cursor's hotspot
  87. * intersected that resulted in the previous dragEnter() invocation
  88. * no longer has an active <code>DropTarget</code> or
  89. * <code>DropTargetListener</code> associated with it.
  90. * </UL>
  91. * OR
  92. * <UL>
  93. * <LI> The current <code>DropTarget</code>'s
  94. * <code>DropTargetListener</code> has invoked rejectDrag()
  95. * since the last dragEnter() or dragOver() invocation.
  96. * </UL>
  97. * <P>
  98. * @param dse the <code>DragSourceEvent</code>
  99. */
  100. void dragExit(DragSourceEvent dse);
  101. /**
  102. * This method is invoked to signify that the Drag and Drop
  103. * operation is complete. The getDropSuccess() method of
  104. * the <code>DragSourceDropEvent</code> can be used to
  105. * determine the termination state. The getDropAction() method
  106. * returns the operation that the <code>DropTarget</code>
  107. * selected (via the DropTargetDropEvent acceptDrop() parameter)
  108. * to apply to the Drop operation. Once this method is complete, the
  109. * current <code>DragSourceContext</code> and
  110. * associated resources become invalid.
  111. * <P>
  112. * @param dsde the <code>DragSourceDropEvent</code>
  113. */
  114. void dragDropEnd(DragSourceDropEvent dsde);
  115. }