1. /*
  2. * @(#)MouseDragGestureRecognizer.java 1.12 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.awt.Component;
  9. import java.awt.event.MouseEvent;
  10. import java.awt.event.MouseListener;
  11. import java.awt.event.MouseMotionListener;
  12. /**
  13. * This abstract subclass of <code>DragGestureRecognizer</code>
  14. * defines a <code>DragGestureRecognizer</code>
  15. * for mouse based gestures.
  16. *
  17. * Each platform will implement its own concrete subclass of this class,
  18. * available via the Toolkit.createDragGestureRecognizer() method,
  19. * to encapsulate
  20. * the recognition of the platform dependent mouse gesture(s) that initiate
  21. * a Drag and Drop operation.
  22. *
  23. * @author Laurence P. G. Cable
  24. * @version 1.12
  25. *
  26. * @see java.awt.dnd.DragGestureListener
  27. * @see java.awt.dnd.DragGestureEvent
  28. * @see java.awt.dnd.DragSource
  29. */
  30. public abstract class MouseDragGestureRecognizer extends DragGestureRecognizer implements MouseListener, MouseMotionListener {
  31. private static final long serialVersionUID = 6220099344182281120L;
  32. /**
  33. * Construct a new <code>MouseDragGestureRecognizer</code>
  34. * given the <code>DragSource</code> for the
  35. * <code>Component</code> c, the <code>Component</code>
  36. * to observe, the action(s)
  37. * permitted for this drag operation, and
  38. * the <code>DragGestureListener</code> to
  39. * notify when a drag gesture is detected.
  40. * <P>
  41. * @param ds The DragSource for the Component c
  42. * @param c The Component to observe
  43. * @param act The actions permitted for this Drag
  44. * @param dgl The DragGestureListener to notify when a gesture is detected
  45. *
  46. */
  47. protected MouseDragGestureRecognizer(DragSource ds, Component c, int act, DragGestureListener dgl) {
  48. super(ds, c, act, dgl);
  49. }
  50. /**
  51. * Construct a new <code>MouseDragGestureRecognizer</code>
  52. * given the <code>DragSource</code> for
  53. * the <code>Component</code> c,
  54. * the <code>Component</code> to observe, and the action(s)
  55. * permitted for this drag operation.
  56. * <P>
  57. * @param ds The DragSource for the Component c
  58. * @param c The Component to observe
  59. * @param act The actions permitted for this drag
  60. */
  61. protected MouseDragGestureRecognizer(DragSource ds, Component c, int act) {
  62. this(ds, c, act, null);
  63. }
  64. /**
  65. * Construct a new <code>MouseDragGestureRecognizer</code>
  66. * given the <code>DragSource</code> for the
  67. * <code>Component</code> c, and the
  68. * <code>Component</code> to observe.
  69. * <P>
  70. * @param ds The DragSource for the Component c
  71. * @param c The Component to observe
  72. */
  73. protected MouseDragGestureRecognizer(DragSource ds, Component c) {
  74. this(ds, c, DnDConstants.ACTION_NONE);
  75. }
  76. /**
  77. * Construct a new <code>MouseDragGestureRecognizer</code>
  78. * given the <code>DragSource</code> for the <code>Component</code>.
  79. * <P>
  80. * @param ds The DragSource for the Component
  81. */
  82. protected MouseDragGestureRecognizer(DragSource ds) {
  83. this(ds, null);
  84. }
  85. /**
  86. * register this DragGestureRecognizer's Listeners with the Component
  87. */
  88. protected void registerListeners() {
  89. component.addMouseListener(this);
  90. component.addMouseMotionListener(this);
  91. }
  92. /**
  93. * unregister this DragGestureRecognizer's Listeners with the Component
  94. *
  95. * subclasses must override this method
  96. */
  97. protected void unregisterListeners() {
  98. component.removeMouseListener(this);
  99. component.removeMouseMotionListener(this);
  100. }
  101. /**
  102. * Invoked when the mouse has been clicked on a component.
  103. * <P>
  104. * @param e the <code>MouseEvent</code>
  105. */
  106. public void mouseClicked(MouseEvent e) { }
  107. /**
  108. * Invoked when a mouse button has been
  109. * pressed on a <code>Component</code>.
  110. * <P>
  111. * @param e the <code>MouseEvent</code>
  112. */
  113. public void mousePressed(MouseEvent e) { }
  114. /**
  115. * Invoked when a mouse button has been released on a component.
  116. * <P>
  117. * @param e the <code>MouseEvent</code>
  118. */
  119. public void mouseReleased(MouseEvent e) { }
  120. /**
  121. * Invoked when the mouse enters a component.
  122. * <P>
  123. * @param e the <code>MouseEvent</code>
  124. */
  125. public void mouseEntered(MouseEvent e) { }
  126. /**
  127. * Invoked when the mouse exits a component.
  128. * <P>
  129. * @param e the <code>MouseEvent</code>
  130. */
  131. public void mouseExited(MouseEvent e) { }
  132. /**
  133. * Invoked when a mouse button is pressed on a component.
  134. * <P>
  135. * @param e the <code>MouseEvent</code>
  136. */
  137. public void mouseDragged(MouseEvent e) { }
  138. /**
  139. * Invoked when the mouse button has been moved on a component
  140. * (with no buttons no down).
  141. * <P>
  142. * @param e the <code>MouseEvent</code>
  143. */
  144. public void mouseMoved(MouseEvent e) { }
  145. }