1. /*
  2. * @(#)DropTargetListener.java 1.20 03/01/23
  3. *
  4. * Copyright 2003 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.DropTargetContext;
  10. import java.awt.dnd.DropTargetDragEvent;
  11. import java.awt.dnd.DropTargetDropEvent;
  12. /**
  13. * The <code>DropTargetListener</code> interface
  14. * is the callback interface used by the
  15. * <code>DropTarget</code> class to provide
  16. * notification of DnD operations that involve
  17. * the subject <code>DropTarget</code>. Methods of
  18. * this interface may be implemented to provide
  19. * "drag under" visual feedback to the user throughout
  20. * the Drag and Drop operation.
  21. * <p>
  22. * Create a listener object by implementing the interface and then register it
  23. * with a <code>DropTarget</code>. When the drag enters, moves over, or exits
  24. * the operable part of the drop site for that <code>DropTarget</code>, when
  25. * the drop action changes, and when the drop occurs, the relevant method in
  26. * the listener object is invoked, and the <code>DropTargetEvent</code> is
  27. * passed to it.
  28. * <p>
  29. * The operable part of the drop site for the <code>DropTarget</code> is
  30. * the part of the associated <code>Component</code>'s geometry that is not
  31. * obscured by an overlapping top-level window or by another
  32. * <code>Component</code> higher in the Z-order that has an associated active
  33. * <code>DropTarget</code>.
  34. *
  35. * @version 1.20, 01/23/03
  36. * @since 1.2
  37. */
  38. public interface DropTargetListener extends EventListener {
  39. /**
  40. * Called while a drag operation is ongoing, when the mouse pointer enters
  41. * the operable part of the drop site for the <code>DropTarget</code>
  42. * registered with this listener.
  43. *
  44. * @param dtde the <code>DropTargetDragEvent</code>
  45. */
  46. void dragEnter(DropTargetDragEvent dtde);
  47. /**
  48. * Called when a drag operation is ongoing, while the mouse pointer is still
  49. * over the operable part of the drop site for the <code>DropTarget</code>
  50. * registered with this listener.
  51. *
  52. * @param dtde the <code>DropTargetDragEvent</code>
  53. */
  54. void dragOver(DropTargetDragEvent dtde);
  55. /**
  56. * Called if the user has modified
  57. * the current drop gesture.
  58. * <P>
  59. * @param dtde the <code>DropTargetDragEvent</code>
  60. */
  61. void dropActionChanged(DropTargetDragEvent dtde);
  62. /**
  63. * Called while a drag operation is ongoing, when the mouse pointer has
  64. * exited the operable part of the drop site for the
  65. * <code>DropTarget</code> registered with this listener.
  66. *
  67. * @param dte the <code>DropTargetEvent</code>
  68. */
  69. void dragExit(DropTargetEvent dte);
  70. /**
  71. * Called when the drag operation has terminated with a drop on
  72. * the operable part of the drop site for the <code>DropTarget</code>
  73. * registered with this listener.
  74. * <p>
  75. * This method is responsible for undertaking
  76. * the transfer of the data associated with the
  77. * gesture. The <code>DropTargetDropEvent</code>
  78. * provides a means to obtain a <code>Transferable</code>
  79. * object that represents the data object(s) to
  80. * be transfered.<P>
  81. * From this method, the <code>DropTargetListener</code>
  82. * shall accept or reject the drop via the
  83. * acceptDrop(int dropAction) or rejectDrop() methods of the
  84. * <code>DropTargetDropEvent</code> parameter.
  85. * <P>
  86. * Subsequent to acceptDrop(), but not before,
  87. * <code>DropTargetDropEvent</code>'s getTransferable()
  88. * method may be invoked, and data transfer may be
  89. * performed via the returned <code>Transferable</code>'s
  90. * getTransferData() method.
  91. * <P>
  92. * At the completion of a drop, an implementation
  93. * of this method is required to signal the success/failure
  94. * of the drop by passing an appropriate
  95. * <code>boolean</code> to the <code>DropTargetDropEvent</code>'s
  96. * dropComplete(boolean success) method.
  97. * <P>
  98. * Note: The data transfer should be completed before the call to the
  99. * <code>DropTargetDropEvent</code>'s dropComplete(boolean success) method.
  100. * After that, a call to the getTransferData() method of the
  101. * <code>Transferable</code> returned by
  102. * <code>DropTargetDropEvent.getTransferable()</code> is guaranteed to
  103. * succeed only if the data transfer is local; that is, only if
  104. * <code>DropTargetDropEvent.isLocalTransfer()</code> returns
  105. * <code>true</code>. Otherwise, the behavior of the call is
  106. * implementation-dependent.
  107. * <P>
  108. * @param dtde the <code>DropTargetDropEvent</code>
  109. */
  110. void drop(DropTargetDropEvent dtde);
  111. }