1. /*
  2. * @(#)MouseDragGestureRecognizer.java 1.8 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.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.8
  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. /**
  32. * Construct a new <code>MouseDragGestureRecognizer</code>
  33. * given the <code>DragSource</code> for the
  34. * <code>Component</code> c, the <code>Component</code>
  35. * to observe, the action(s)
  36. * permitted for this drag operation, and
  37. * the <code>DragGestureListener</code> to
  38. * notify when a drag gesture is detected.
  39. * <P>
  40. * @param ds The DragSource for the Component c
  41. * @param c The Component to observe
  42. * @param act The actions permitted for this Drag
  43. * @param dgl The DragGestureListener to notify when a gesture is detected
  44. *
  45. */
  46. protected MouseDragGestureRecognizer(DragSource ds, Component c, int act, DragGestureListener dgl) {
  47. super(ds, c, act, dgl);
  48. }
  49. /**
  50. * Construct a new <code>MouseDragGestureRecognizer</code>
  51. * given the <code>DragSource</code> for
  52. * the <code>Component</code> c,
  53. * the <code>Component</code> to observe, and the action(s)
  54. * permitted for this drag operation.
  55. * <P>
  56. * @param ds The DragSource for the Component c
  57. * @param c The Component to observe
  58. * @param act The actions permitted for this drag
  59. */
  60. protected MouseDragGestureRecognizer(DragSource ds, Component c, int act) {
  61. this(ds, c, act, null);
  62. }
  63. /**
  64. * Construct a new <code>MouseDragGestureRecognizer</code>
  65. * given the <code>DragSource</code> for the
  66. * <code>Component</code> c, and the
  67. * <code>Component</code> to observe.
  68. * <P>
  69. * @param ds The DragSource for the Component c
  70. * @param c The Component to observe
  71. */
  72. protected MouseDragGestureRecognizer(DragSource ds, Component c) {
  73. this(ds, c, DnDConstants.ACTION_NONE);
  74. }
  75. /**
  76. * Construct a new <code>MouseDragGestureRecognizer</code>
  77. * given the <code>DragSource</code> for the <code>Component</code>.
  78. * <P>
  79. * @param ds The DragSource for the Component
  80. */
  81. protected MouseDragGestureRecognizer(DragSource ds) {
  82. this(ds, null);
  83. }
  84. /**
  85. * register this DragGestureRecognizer's Listeners with the Component
  86. */
  87. protected void registerListeners() {
  88. component.addMouseListener(this);
  89. component.addMouseMotionListener(this);
  90. }
  91. /**
  92. * unregister this DragGestureRecognizer's Listeners with the Component
  93. *
  94. * subclasses must override this method
  95. */
  96. protected void unregisterListeners() {
  97. component.removeMouseListener(this);
  98. component.removeMouseMotionListener(this);
  99. }
  100. /**
  101. * Invoked when the mouse has been clicked on a component.
  102. * <P>
  103. * @param e the <code>MouseEvent</code>
  104. */
  105. public void mouseClicked(MouseEvent e) { }
  106. /**
  107. * Invoked when a mouse button has been
  108. * pressed on a <code>Component</code>.
  109. * <P>
  110. * @param e the <code>MouseEvent</code>
  111. */
  112. public void mousePressed(MouseEvent e) { }
  113. /**
  114. * Invoked when a mouse button has been released on a component.
  115. * <P>
  116. * @param e the <code>MouseEvent</code>
  117. */
  118. public void mouseReleased(MouseEvent e) { }
  119. /**
  120. * Invoked when the mouse enters a component.
  121. * <P>
  122. * @param e the <code>MouseEvent</code>
  123. */
  124. public void mouseEntered(MouseEvent e) { }
  125. /**
  126. * Invoked when the mouse exits a component.
  127. * <P>
  128. * @param e the <code>MouseEvent</code>
  129. */
  130. public void mouseExited(MouseEvent e) { }
  131. /**
  132. * Invoked when a mouse button is pressed on a component.
  133. * <P>
  134. * @param e the <code>MouseEvent</code>
  135. */
  136. public void mouseDragged(MouseEvent e) { }
  137. /**
  138. * Invoked when the mouse button has been moved on a component
  139. * (with no buttons no down).
  140. * <P>
  141. * @param e the <code>MouseEvent</code>
  142. */
  143. public void mouseMoved(MouseEvent e) { }
  144. }