org.zaval.awt.gdp
Class DragController


java.lang.Object

  |

  +--org.zaval.awt.gdp.Controller

        |

        +--org.zaval.awt.gdp.DragController

All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

public class DragController
extends Controller
implements java.awt.event.MouseMotionListener, java.awt.event.MouseListener

This controller is used to convert mouse events of the target component to the mouse org.zaval.awt.gdp.event.MouseDragEvent events. To listen the events use addMouseDragListener and removeMouseDragListener methods. The main purpose of the class is to provide more handy method to handle mouse drag events for the specified component.


Constructor Summary
DragController(java.awt.Component target)
           Constructs a new drag controller with the specified target component.
 
Method Summary
 void addMouseDragListener(MouseDragListener l)
           Adds the specified drag listener.
 boolean isDragged()
           Tests if the mouse is dragged at the moment.
 void mouseClicked(java.awt.event.MouseEvent e)
           Invoked when the mouse has been clicked on a component.
 void mouseDragged(java.awt.event.MouseEvent e)
           Invoked when a mouse button is pressed on a component and then dragged.
 void mouseEntered(java.awt.event.MouseEvent e)
           Invoked when the mouse enters a component.
 void mouseExited(java.awt.event.MouseEvent e)
           Invoked when the mouse exits a component.
 void mouseMoved(java.awt.event.MouseEvent e)
           Invoked when the mouse button has been moved on a component (with no buttons no down).
 void mousePressed(java.awt.event.MouseEvent e)
           Invoked when a mouse button has been pressed on a component.
 void mouseReleased(java.awt.event.MouseEvent e)
           Invoked when a mouse button has been released on a component.
protected  void perform(MouseDragEvent e)
           Performs the specified mouse drag event.
 void removeMouseDragListener(MouseDragListener l)
           Removes the specified drag listener.
protected  void targetWasChanged(java.awt.Component n, java.awt.Component o)
           The method is called whenever the target component has been changed.
 
Methods inherited from class org.zaval.awt.gdp.Controller
getTarget, setTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragController


public DragController(java.awt.Component target)
Constructs a new drag controller with the specified target component.
Parameters:
target - the specified target component.
Method Detail

addMouseDragListener


public void addMouseDragListener(MouseDragListener l)
Adds the specified drag listener.
Parameters:
l - the specified drag listener.

removeMouseDragListener


public void removeMouseDragListener(MouseDragListener l)
Removes the specified drag listener.
Parameters:
l - the specified drag listener.

isDragged


public boolean isDragged()
Tests if the mouse is dragged at the moment.
Returns:
true if the mouse is dragged; false otherwise.

mouseDragged


public void mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged. Mouse drag events will continue to be delivered to the component where the first originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseReleased


public void mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released on a component.
Specified by:
mouseReleased in interface java.awt.event.MouseListener

targetWasChanged


protected void targetWasChanged(java.awt.Component n,
                                java.awt.Component o)
The method is called whenever the target component has been changed. The implementation removes mouse and mouse motion listeners for the old target and registers the listeners for the new target component.
Overrides:
targetWasChanged in class Controller
Parameters:
n - the specified new target component.
o - the specified old target component.

perform


protected void perform(MouseDragEvent e)
Performs the specified mouse drag event.
Parameters:
e - the specified mouse drag event.

mousePressed


public void mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed on a component.
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseMoved


public void mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse button has been moved on a component (with no buttons no down).
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseClicked


public void mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse has been clicked on a component.
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered


public void mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a component.
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited


public void mouseExited(java.awt.event.MouseEvent e)
Invoked when the mouse exits a component.
Specified by:
mouseExited in interface java.awt.event.MouseListener


Copyright © Zaval Creative Engineering Group, 2000-2005
http://www.zaval.org