|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectframework.MouseState
public class MouseState
Listens to MouseEvent events to build a model of the state of the mouse.
Example usage:
public class MouseDemo extends Game
{
private MouseState mouse = new MouseState();
public void init ()
{
// use for detecting clicks
addMouseListener(mouse);
// updates mouse position constantly
addMouseMotionListener(mouse);
// use for detecting mouse wheel scrolling
addMouseWheelListener(mouse);
}
public void update (int time)
{
mouse.update();
Point2D p = mouse.getPosition();
if (mouse.leftClicked())
{
...
}
}
}
| Constructor Summary | |
|---|---|
MouseState()
|
|
| Method Summary | |
|---|---|
boolean |
doubleClicked()
|
int |
getDX()
|
int |
getDY()
|
Point |
getLastKnownPosition()
Returns the last position the mouse was known to be at. |
Point |
getMovement()
|
Point |
getPosition()
Returns the mouse position. |
int |
getWheelRotation()
|
int |
getX()
Note: returns -1 if mouse is not over component |
int |
getY()
Note: returns -1 if mouse is not over component |
boolean |
leftClicked()
|
boolean |
leftDown()
|
boolean |
middleClicked()
|
boolean |
middleDown()
|
void |
mouseClicked(MouseEvent e)
Required for MouseListener interface. |
void |
mouseDragged(MouseEvent e)
Required for MouseMotionListener interface. |
void |
mouseEntered(MouseEvent e)
Required for MouseListener interface. |
void |
mouseExited(MouseEvent e)
Required for MouseListener interface. |
void |
mouseMoved(MouseEvent e)
Required for MouseMotionListener interface. |
void |
mousePressed(MouseEvent e)
Required for MouseListener interface. |
void |
mouseReleased(MouseEvent e)
Required for MouseListener interface. |
void |
mouseWheelMoved(MouseWheelEvent e)
Required for MouseMotionListener interface. |
boolean |
rightClicked()
|
boolean |
rightDown()
|
void |
update()
Process events which have been received since the last call to this method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MouseState()
| Method Detail |
|---|
public void update()
public boolean leftClicked()
public boolean middleClicked()
public boolean rightClicked()
public boolean doubleClicked()
public boolean leftDown()
public boolean middleDown()
public boolean rightDown()
public Point getPosition()
getLastKnownPosition().
This needs to be added as a MouseMotionListener listener to get meaningful results from this method.
public Point getLastKnownPosition()
MouseMotionListener listener to get meaningful results from this method.
public int getX()
public int getY()
public Point getMovement()
public int getDX()
public int getDY()
public int getWheelRotation()
public void mouseClicked(MouseEvent e)
MouseListener interface.
mouseClicked in interface MouseListenerpublic void mouseEntered(MouseEvent e)
MouseListener interface.
mouseEntered in interface MouseListenerpublic void mouseExited(MouseEvent e)
MouseListener interface.
mouseExited in interface MouseListenerpublic void mousePressed(MouseEvent e)
MouseListener interface.
mousePressed in interface MouseListenerpublic void mouseReleased(MouseEvent e)
MouseListener interface.
mouseReleased in interface MouseListenerpublic void mouseDragged(MouseEvent e)
MouseMotionListener interface.
mouseDragged in interface MouseMotionListenerpublic void mouseMoved(MouseEvent e)
MouseMotionListener interface.
mouseMoved in interface MouseMotionListenerpublic void mouseWheelMoved(MouseWheelEvent e)
MouseMotionListener interface.
mouseWheelMoved in interface MouseWheelListener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||