1. /*
  2. * @(#)DragSourceDropEvent.java 1.19 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. * The <code>DragSourceDropEvent</code> is delivered
  10. * from the <code>DragSourceContextPeer</code>,
  11. * via the <code>DragSourceContext</code>, to the <code>dragDropEnd</code>
  12. * method of <code>DragSourceListener</code>s registered with that
  13. * <code>DragSourceContext</code> and with its associated
  14. * <code>DragSource</code>.
  15. * It contains sufficient information for the
  16. * originator of the operation
  17. * to provide appropriate feedback to the end user
  18. * when the operation completes.
  19. * <P>
  20. * @version 1.19, 12/19/03
  21. * <P>
  22. * @since 1.2
  23. */
  24. public class DragSourceDropEvent extends DragSourceEvent {
  25. private static final long serialVersionUID = -5571321229470821891L;
  26. /**
  27. * Construct a <code>DragSourceDropEvent</code> for a drop,
  28. * given the
  29. * <code>DragSourceContext</code>, the drop action,
  30. * and a <code>boolean</code> indicating if the drop was successful.
  31. * The coordinates for this <code>DragSourceDropEvent</code>
  32. * are not specified, so <code>getLocation</code> will return
  33. * <code>null</code> for this event.
  34. * <p>
  35. * The argument <code>action</code> should be one of <code>DnDConstants</code>
  36. * that represents a single action.
  37. * This constructor does not throw any exception for invalid <code>action</code>.
  38. *
  39. * @param dsc the <code>DragSourceContext</code>
  40. * associated with this <code>DragSourceDropEvent</code>
  41. * @param action the drop action
  42. * @param success a boolean indicating if the drop was successful
  43. *
  44. * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
  45. *
  46. * @see DragSourceEvent#getLocation
  47. */
  48. public DragSourceDropEvent(DragSourceContext dsc, int action, boolean success) {
  49. super(dsc);
  50. dropSuccess = success;
  51. dropAction = action;
  52. }
  53. /**
  54. * Construct a <code>DragSourceDropEvent</code> for a drop, given the
  55. * <code>DragSourceContext</code>, the drop action, a <code>boolean</code>
  56. * indicating if the drop was successful, and coordinates.
  57. * <p>
  58. * The argument <code>action</code> should be one of <code>DnDConstants</code>
  59. * that represents a single action.
  60. * This constructor does not throw any exception for invalid <code>action</code>.
  61. *
  62. * @param dsc the <code>DragSourceContext</code>
  63. * associated with this <code>DragSourceDropEvent</code>
  64. * @param action the drop action
  65. * @param success a boolean indicating if the drop was successful
  66. * @param x the horizontal coordinate for the cursor location
  67. * @param y the vertical coordinate for the cursor location
  68. *
  69. * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
  70. *
  71. * @since 1.4
  72. */
  73. public DragSourceDropEvent(DragSourceContext dsc, int action,
  74. boolean success, int x, int y) {
  75. super(dsc, x, y);
  76. dropSuccess = success;
  77. dropAction = action;
  78. }
  79. /**
  80. * Construct a <code>DragSourceDropEvent</code>
  81. * for a drag that does not result in a drop.
  82. * The coordinates for this <code>DragSourceDropEvent</code>
  83. * are not specified, so <code>getLocation</code> will return
  84. * <code>null</code> for this event.
  85. *
  86. * @param dsc the <code>DragSourceContext</code>
  87. *
  88. * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
  89. *
  90. * @see DragSourceEvent#getLocation
  91. */
  92. public DragSourceDropEvent(DragSourceContext dsc) {
  93. super(dsc);
  94. dropSuccess = false;
  95. }
  96. /**
  97. * This method returns a <code>boolean</code> indicating
  98. * if the drop was successful.
  99. *
  100. * @return <code>true</code> if the drop target accepted the drop and
  101. * successfully performed a drop action;
  102. * <code>false</code> if the drop target rejected the drop or
  103. * if the drop target accepted the drop, but failed to perform
  104. * a drop action.
  105. */
  106. public boolean getDropSuccess() { return dropSuccess; }
  107. /**
  108. * This method returns an <code>int</code> representing
  109. * the action performed by the target on the subject of the drop.
  110. *
  111. * @return the action performed by the target on the subject of the drop
  112. * if the drop target accepted the drop and the target drop action
  113. * is supported by the drag source; otherwise,
  114. * <code>DnDConstants.ACTION_NONE</code>.
  115. */
  116. public int getDropAction() { return dropAction; }
  117. /*
  118. * fields
  119. */
  120. /**
  121. * <code>true</code> if the drop was successful.
  122. *
  123. * @serial
  124. */
  125. private boolean dropSuccess;
  126. /**
  127. * The drop action.
  128. *
  129. * @serial
  130. */
  131. private int dropAction = DnDConstants.ACTION_NONE;
  132. }