1. /*
  2. * @(#)DragSourceDropEvent.java 1.17 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. /**
  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.17, 01/23/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. *
  35. * @param dsc the <code>DragSourceContext</code>
  36. * associated with this <code>DragSourceDropEvent</code>
  37. * @param action the drop action
  38. * @param success a boolean indicating if the drop was successful
  39. * @see DragSourceEvent#getLocation
  40. */
  41. public DragSourceDropEvent(DragSourceContext dsc, int action, boolean success) {
  42. super(dsc);
  43. dropSuccess = success;
  44. dropAction = action;
  45. }
  46. /**
  47. * Construct a <code>DragSourceDropEvent</code> for a drop, given the
  48. * <code>DragSourceContext</code>, the drop action, a <code>boolean</code>
  49. * indicating if the drop was successful, and coordinates.
  50. *
  51. * @param dsc the <code>DragSourceContext</code>
  52. * associated with this <code>DragSourceDropEvent</code>
  53. * @param action the drop action
  54. * @param success a boolean indicating if the drop was successful
  55. * @param x the horizontal coordinate for the cursor location
  56. * @param y the vertical coordinate for the cursor location
  57. * @since 1.4
  58. */
  59. public DragSourceDropEvent(DragSourceContext dsc, int action,
  60. boolean success, int x, int y) {
  61. super(dsc, x, y);
  62. dropSuccess = success;
  63. dropAction = action;
  64. }
  65. /**
  66. * Construct a <code>DragSourceDropEvent</code>
  67. * for a drag that does not result in a drop.
  68. * The coordinates for this <code>DragSourceDropEvent</code>
  69. * are not specified, so <code>getLocation</code> will return
  70. * <code>null</code> for this event.
  71. *
  72. * @param dsc the <code>DragSourceContext</code>
  73. * @see DragSourceEvent#getLocation
  74. */
  75. public DragSourceDropEvent(DragSourceContext dsc) {
  76. super(dsc);
  77. dropSuccess = false;
  78. }
  79. /**
  80. * This method returns a <code>boolean</code> indicating
  81. * if the drop was successful.
  82. *
  83. * @return <code>true</code> if the drop target accepted the drop and
  84. * successfully performed a drop action;
  85. * <code>false</code> if the drop target rejected the drop or
  86. * if the drop target accepted the drop, but failed to perform
  87. * a drop action.
  88. */
  89. public boolean getDropSuccess() { return dropSuccess; }
  90. /**
  91. * This method returns an <code>int</code> representing
  92. * the action performed by the target on the subject of the drop.
  93. *
  94. * @return the action performed by the target on the subject of the drop
  95. * if the drop target accepted the drop and the target drop action
  96. * is supported by the drag source; otherwise,
  97. * <code>DnDConstants.ACTION_NONE</code>.
  98. */
  99. public int getDropAction() { return dropAction; }
  100. /*
  101. * fields
  102. */
  103. /**
  104. * <code>true</code> if the drop was successful.
  105. *
  106. * @serial
  107. */
  108. private boolean dropSuccess;
  109. /**
  110. * The drop action.
  111. *
  112. * @serial
  113. */
  114. private int dropAction = DnDConstants.ACTION_NONE;
  115. }