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