javalib.funworld
Class MyMouseAdapter

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by javalib.funworld.MyMouseAdapter
All Implemented Interfaces:
MouseListener, MouseMotionListener, MouseWheelListener, EventListener

 class MyMouseAdapter
extends MouseAdapter

The implementation of callbacks for the mouse events: mouse clicked, entered, exited, pressed, and released.

We do not handle mouse motion events: mouse dragged and mouse moved.

Since:
August 2, 2007
Author:
Viera K. Proulx

Field Summary
protected  World currentWorld
          the current World that handles the mouse events
protected  Posn mousePosn
          the mouse position recorded by the mouse event handler
 
Constructor Summary
protected MyMouseAdapter(World currentWorld)
          Create the mouse listener for the given World.
 
Method Summary
(package private)  Posn adjustMousePosn(Posn mousePosn)
          Adjust the reported mouse position to account for the top bar
 void mouseClicked(MouseEvent e)
          Invoked when the mouse has been clicked on a component.
 void mouseDragged(MouseEvent e)
          Invoked when the mouse has been dragged in a component.
 void mouseEntered(MouseEvent e)
          Invoked when the mouse enters a component.
 void mouseExited(MouseEvent e)
          Invoked when the mouse exits a component.
 void mouseMoved(MouseEvent e)
          Invoked when the mouse has been moved in a component.
 void mousePressed(MouseEvent e)
          Invoked when the mouse button has been pressed on a component.
 void mouseReleased(MouseEvent e)
          Invoked when a mouse button has been released on a component.
 
Methods inherited from class java.awt.event.MouseAdapter
mouseWheelMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentWorld

protected World currentWorld
the current World that handles the mouse events


mousePosn

protected Posn mousePosn
the mouse position recorded by the mouse event handler

Constructor Detail

MyMouseAdapter

protected MyMouseAdapter(World currentWorld)
Create the mouse listener for the given World.

Parameters:
currentWorld - the given World
Method Detail

adjustMousePosn

Posn adjustMousePosn(Posn mousePosn)
Adjust the reported mouse position to account for the top bar

Parameters:
mousePosn - the recorded mouse position
Returns:
the actual mouse position

mouseClicked

public void mouseClicked(MouseEvent e)
Invoked when the mouse has been clicked on a component.

Specified by:
mouseClicked in interface MouseListener
Overrides:
mouseClicked in class MouseAdapter
Parameters:
e - the mouse event that invoked this callback

mouseDragged

public void mouseDragged(MouseEvent e)
Invoked when the mouse has been dragged in a component.

Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class MouseAdapter
Parameters:
e - the mouse event that invoked this callback

mouseEntered

public void mouseEntered(MouseEvent e)
Invoked when the mouse enters a component.

Specified by:
mouseEntered in interface MouseListener
Overrides:
mouseEntered in class MouseAdapter
Parameters:
e - the mouse event that invoked this callback

mouseExited

public void mouseExited(MouseEvent e)
Invoked when the mouse exits a component.

Specified by:
mouseExited in interface MouseListener
Overrides:
mouseExited in class MouseAdapter
Parameters:
e - the mouse event that invoked this callback

mouseMoved

public void mouseMoved(MouseEvent e)
Invoked when the mouse has been moved in a component.

Specified by:
mouseMoved in interface MouseMotionListener
Overrides:
mouseMoved in class MouseAdapter
Parameters:
e - the mouse event that invoked this callback

mousePressed

public void mousePressed(MouseEvent e)
Invoked when the mouse button has been pressed on a component.

Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class MouseAdapter
Parameters:
e - the mouse event that invoked this callback

mouseReleased

public void mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a component.

Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class MouseAdapter
Parameters:
e - the mouse event that invoked this callback