org.zaval.awt.gdp
Class CursorController


java.lang.Object

  |

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

        |

        +--org.zaval.awt.gdp.CursorController

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

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

This cursor controller class can be used to control cursor type for the specified target component. Use the controller according to the following:

The controller registers itself as MouseMotionListener and MouseListener listeners of the target component to control cursor type.


Constructor Summary
CursorController(java.awt.Component target)
           Constructs a new cursor controller with the specified target component.
CursorController(java.awt.Component target, CursorInfo i)
           Constructs a new cursor controller with the specified target component and the given cursor info.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
           Adds the specified action listener.
protected  void changeCursor(int x, int y)
           The method checks if the cursor type has to be changed for the specified location relatively the target component and sets a new cursor type if it is necessary.
 int getCursorType()
           Gets the current cursor type.
 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()
           Performs an action event.
 void removeActionListener(java.awt.event.ActionListener l)
           Removes the specified action listener.
protected  void restoreCursor()
           Sets the cursor type.
 void setCursorInfo(CursorInfo i)
           Sets the specified cursor info.
protected  void setCursorType(int type)
           Sets the specified cursor type.
protected  void storeCursor()
           Stores a current cursor type.
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

CursorController


public CursorController(java.awt.Component target)
Constructs a new cursor controller with the specified target component.
Parameters:
target - the specified target component.

CursorController


public CursorController(java.awt.Component target,
                        CursorInfo i)
Constructs a new cursor controller with the specified target component and the given cursor info.
Parameters:
target - the specified target component.
i - the specified cursor info.
Method Detail

setCursorInfo


public void setCursorInfo(CursorInfo i)
Sets the specified cursor info. The cursor info defines mouse cursor type depending on the the mouse pointer location relatively the target component.
Parameters:
i - the specified cursor info.

addActionListener


public void addActionListener(java.awt.event.ActionListener l)
Adds the specified action listener. The action event is performed when the cursor type has been changed for the target component.
Parameters:
l - the specified action listener.

removeActionListener


public void removeActionListener(java.awt.event.ActionListener l)
Removes the specified action listener.
Parameters:
l - the specified action listener.

getCursorType


public int getCursorType()
Gets the current cursor type.
Returns:
a cursor type.

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

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

changeCursor


protected void changeCursor(int x,
                            int y)
The method checks if the cursor type has to be changed for the specified location relatively the target component and sets a new cursor type if it is necessary.
Parameters:
x - the specified x cordinate relatively the target component.
y - the specified y cordinate relatively the target component.

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

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

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 method 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()
Performs an action event.

setCursorType


protected void setCursorType(int type)
Sets the specified cursor type. The method is used to store the new cursor type in the internal field and perform an action event.
Parameters:
type - the specified cursor type.

storeCursor


protected void storeCursor()
Stores a current cursor type.

restoreCursor


protected void restoreCursor()
Sets the cursor type. The method uses a cursor type that has been stored with storeCursor method.


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