org.newdawn.slick.gui
Class MouseOverArea

java.lang.Object
  extended by org.newdawn.slick.util.InputAdapter
      extended by org.newdawn.slick.gui.AbstractComponent
          extended by org.newdawn.slick.gui.MouseOverArea
All Implemented Interfaces:
ControlledInputReciever, ControllerListener, InputListener, KeyListener, MouseListener

public class MouseOverArea
extends AbstractComponent

A mouse over area that can be used for menus or buttons

Author:
kevin

Field Summary
 
Fields inherited from class org.newdawn.slick.gui.AbstractComponent
container, input, listeners
 
Constructor Summary
MouseOverArea(GUIContext container, Image image, int x, int y)
          Create a new mouse over area
MouseOverArea(GUIContext container, Image image, int x, int y, ComponentListener listener)
          Create a new mouse over area
MouseOverArea(GUIContext container, Image image, int x, int y, int width, int height)
          Create a new mouse over area
MouseOverArea(GUIContext container, Image image, int x, int y, int width, int height, ComponentListener listener)
          Create a new mouse over area
MouseOverArea(GUIContext container, Image image, Shape shape)
          Create a new mouse over area
 
Method Summary
 int getHeight()
          Get the height of the component
 int getWidth()
          Get the width of the component
 int getX()
          Returns the position in the X coordinate
 int getY()
          Returns the position in the Y coordinate
 boolean isMouseOver()
          Check if the mouse is over this area
 void mouseDragged(int oldx, int oldy, int newx, int newy)
          Notification that mouse cursor was dragged
 void mouseMoved(int oldx, int oldy, int newx, int newy)
          Notification that mouse cursor was moved
 void mousePressed(int button, int mx, int my)
          Notification that a mouse button was pressed
 void mouseReleased(int button, int mx, int my)
          Gives the focus to this component with a click of the mouse.
 void render(GUIContext container, Graphics g)
          Render this component to the screen
 void setLocation(float x, float y)
          Moves the component.
 void setLocation(int x, int y)
          Set the location of this area
 void setMouseDownColor(Color color)
          Set the color to be used when the mouse is down the area
 void setMouseDownImage(Image image)
          Set the image to be used when the mouse is down the area
 void setMouseDownSound(Sound sound)
          Set the mouse down sound effect
 void setMouseOverColor(Color color)
          Set the color to be used when the mouse is over the area
 void setMouseOverImage(Image image)
          Set the image to be used when the mouse is over the area
 void setMouseOverSound(Sound sound)
          Set the mouse over sound effect
 void setNormalColor(Color color)
          Set the normal color used on the image in the default state
 void setNormalImage(Image image)
          Set the normal image used on the image in the default state
 void setX(float x)
          Set the x coordinate of this area
 void setY(float y)
          Set the y coordinate of this area
 
Methods inherited from class org.newdawn.slick.gui.AbstractComponent
addListener, consumeEvent, hasFocus, notifyListeners, removeListener, setFocus
 
Methods inherited from class org.newdawn.slick.util.InputAdapter
controllerButtonPressed, controllerButtonReleased, controllerDownPressed, controllerDownReleased, controllerLeftPressed, controllerLeftReleased, controllerRightPressed, controllerRightReleased, controllerUpPressed, controllerUpReleased, inputEnded, inputStarted, isAcceptingInput, keyPressed, keyReleased, mouseClicked, mouseWheelMoved, setAcceptingInput, setInput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MouseOverArea

public MouseOverArea(GUIContext container,
                     Image image,
                     int x,
                     int y,
                     ComponentListener listener)
Create a new mouse over area

Parameters:
container - The container displaying the mouse over area
image - The normalImage to display
x - The position of the area
y - the position of the area
listener - A listener to add to the area

MouseOverArea

public MouseOverArea(GUIContext container,
                     Image image,
                     int x,
                     int y)
Create a new mouse over area

Parameters:
container - The container displaying the mouse over area
image - The normalImage to display
x - The position of the area
y - the position of the area

MouseOverArea

public MouseOverArea(GUIContext container,
                     Image image,
                     int x,
                     int y,
                     int width,
                     int height,
                     ComponentListener listener)
Create a new mouse over area

Parameters:
container - The container displaying the mouse over area
image - The normalImage to display
x - The position of the area
y - the position of the area
width - The width of the area
height - The height of the area
listener - A listener to add to the area

MouseOverArea

public MouseOverArea(GUIContext container,
                     Image image,
                     int x,
                     int y,
                     int width,
                     int height)
Create a new mouse over area

Parameters:
container - The container displaying the mouse over area
image - The normalImage to display
x - The position of the area
y - the position of the area
width - The width of the area
height - The height of the area

MouseOverArea

public MouseOverArea(GUIContext container,
                     Image image,
                     Shape shape)
Create a new mouse over area

Parameters:
container - The container displaying the mouse over area
image - The normalImage to display
shape - The shape defining the area of the mouse sensitive zone
Method Detail

setLocation

public void setLocation(float x,
                        float y)
Moves the component.

Parameters:
x - X coordinate
y - Y coordinate

setX

public void setX(float x)
Set the x coordinate of this area

Parameters:
x - The new x coordinate of this area

setY

public void setY(float y)
Set the y coordinate of this area

Parameters:
y - The new y coordinate of this area

getX

public int getX()
Returns the position in the X coordinate

Specified by:
getX in class AbstractComponent
Returns:
x

getY

public int getY()
Returns the position in the Y coordinate

Specified by:
getY in class AbstractComponent
Returns:
y

setNormalColor

public void setNormalColor(Color color)
Set the normal color used on the image in the default state

Parameters:
color - The color to be used

setMouseOverColor

public void setMouseOverColor(Color color)
Set the color to be used when the mouse is over the area

Parameters:
color - The color to be used when the mouse is over the area

setMouseDownColor

public void setMouseDownColor(Color color)
Set the color to be used when the mouse is down the area

Parameters:
color - The color to be used when the mouse is down the area

setNormalImage

public void setNormalImage(Image image)
Set the normal image used on the image in the default state

Parameters:
image - The image to be used

setMouseOverImage

public void setMouseOverImage(Image image)
Set the image to be used when the mouse is over the area

Parameters:
image - The image to be used when the mouse is over the area

setMouseDownImage

public void setMouseDownImage(Image image)
Set the image to be used when the mouse is down the area

Parameters:
image - The image to be used when the mouse is down the area

render

public void render(GUIContext container,
                   Graphics g)
Description copied from class: AbstractComponent
Render this component to the screen

Specified by:
render in class AbstractComponent
Parameters:
container - The container displaying this component
g - The graphics context used to render to the display
See Also:
AbstractComponent.render(org.newdawn.slick.gui.GUIContext, org.newdawn.slick.Graphics)

setMouseOverSound

public void setMouseOverSound(Sound sound)
Set the mouse over sound effect

Parameters:
sound - The mouse over sound effect

setMouseDownSound

public void setMouseDownSound(Sound sound)
Set the mouse down sound effect

Parameters:
sound - The mouse down sound effect

mouseMoved

public void mouseMoved(int oldx,
                       int oldy,
                       int newx,
                       int newy)
Description copied from interface: MouseListener
Notification that mouse cursor was moved

Specified by:
mouseMoved in interface MouseListener
Overrides:
mouseMoved in class InputAdapter
Parameters:
oldx - The old x position of the mouse
oldy - The old y position of the mouse
newx - The new x position of the mouse
newy - The new y position of the mouse
See Also:
InputAdapter.mouseMoved(int, int, int, int)

mouseDragged

public void mouseDragged(int oldx,
                         int oldy,
                         int newx,
                         int newy)
Description copied from interface: MouseListener
Notification that mouse cursor was dragged

Specified by:
mouseDragged in interface MouseListener
Overrides:
mouseDragged in class InputAdapter
Parameters:
oldx - The old x position of the mouse
oldy - The old y position of the mouse
newx - The new x position of the mouse
newy - The new y position of the mouse
See Also:
InputAdapter.mouseDragged(int, int, int, int)

mousePressed

public void mousePressed(int button,
                         int mx,
                         int my)
Description copied from interface: MouseListener
Notification that a mouse button was pressed

Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class InputAdapter
Parameters:
button - The index of the button (starting at 0)
mx - The x position of the mouse when the button was pressed
my - The y position of the mouse when the button was pressed
See Also:
InputAdapter.mousePressed(int, int, int)

mouseReleased

public void mouseReleased(int button,
                          int mx,
                          int my)
Description copied from class: AbstractComponent
Gives the focus to this component with a click of the mouse.

Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class AbstractComponent
Parameters:
button - The index of the button (starting at 0)
mx - The x position of the mouse when the button was released
my - The y position of the mouse when the button was released
See Also:
InputAdapter.mouseReleased(int, int, int)

getHeight

public int getHeight()
Description copied from class: AbstractComponent
Get the height of the component

Specified by:
getHeight in class AbstractComponent
Returns:
The height of the component
See Also:
AbstractComponent.getHeight()

getWidth

public int getWidth()
Description copied from class: AbstractComponent
Get the width of the component

Specified by:
getWidth in class AbstractComponent
Returns:
The width of the component
See Also:
AbstractComponent.getWidth()

isMouseOver

public boolean isMouseOver()
Check if the mouse is over this area

Returns:
True if the mouse is over this area

setLocation

public void setLocation(int x,
                        int y)
Set the location of this area

Specified by:
setLocation in class AbstractComponent
Parameters:
x - The x coordinate of this area
y - The y coordiante of this area


Copyright © 2006 New Dawn Software. All Rights Reserved.