|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcodeblocks.JComponentDragHandler
public class JComponentDragHandler
This class can be used to add dragging capability to any JComponents. It contains the methods and data members needed to support automatic dragging, and contains methods to impliment both MouseListener, MouseMotionListener. In general, any existing JComponent can be made to be draggable simple by creating an instance of JComponentDragHandler (passing a reference to itself) and registering the JComponentDragHandler as the listener for all mouse events. Classes that need similar, but not identical, behavior, or that need to add functionality to the mouse methods here can create an inner class that extends this class. In this way the inner class can maintain the functionality of JComponentDragHandler while also having access to data members and methods of its enclosing class for the purposes of extension.
Field Summary | |
---|---|
int |
dragDX
|
int |
dragDY
|
int |
mCurrentX
|
int |
mCurrentY
|
int |
mPressedX
These data members save the point at which the mouse was pressed relative to the (0,0) corner of the JComponent. |
int |
mPressedY
|
java.awt.Point |
myLoc
Stores location data (typically of this JComponent) as a Point for easy manipulation and to avoid re-creating a new object every time these manipulations are done. |
int |
oldLocX
|
int |
oldLocY
|
Constructor Summary | |
---|---|
JComponentDragHandler(javax.swing.JComponent jc)
Creates a new instance of a JComponentDragHandler with a pointer to the given JComponent. |
Method Summary | |
---|---|
java.awt.Cursor |
getDraggingCursor()
Returns the Cursor instance that is used on mouse drags |
java.awt.Cursor |
getDragHintCursor()
Returns the Cursor instance that is used when a mouse is over a draggable object |
java.awt.Point |
getMousePoint()
|
void |
mouseClicked(java.awt.event.MouseEvent arg0)
|
void |
mouseDragged(java.awt.event.MouseEvent e)
This method is called when the mouse is dragged over the JComponent. |
void |
mouseEntered(java.awt.event.MouseEvent arg0)
|
void |
mouseExited(java.awt.event.MouseEvent arg0)
|
void |
mouseMoved(java.awt.event.MouseEvent e)
update the current location of the mouse |
void |
mousePressed(java.awt.event.MouseEvent e)
Called when the mouse is pressed over the JComponent. |
void |
mouseReleased(java.awt.event.MouseEvent e)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int mPressedX
public int mPressedY
public int mCurrentX
public int mCurrentY
public int dragDX
public int dragDY
public int oldLocX
public int oldLocY
public java.awt.Point myLoc
Constructor Detail |
---|
public JComponentDragHandler(javax.swing.JComponent jc)
jc
- the JComponent whose mouse events will be handled by this JComponentDragHandlerMethod Detail |
---|
public java.awt.Cursor getDragHintCursor()
public java.awt.Cursor getDraggingCursor()
public java.awt.Point getMousePoint()
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseClicked(java.awt.event.MouseEvent arg0)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent arg0)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent arg0)
mouseExited
in interface java.awt.event.MouseListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |