Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.newdawn.slick.gui
Class AbstractComponent

    java.lang.Object
      org.newdawn.slick.util.InputAdapter
          org.newdawn.slick.gui.AbstractComponent

All Implemented Interfaces:
  ControlledInputReciever, ControllerListener, InputListener, KeyListener, MouseListener

Direct Known Subclasses:
  BasicComponent, MouseOverArea, TextField

    public abstract class AbstractComponent

extends InputAdapter

The utility class to handle all the input related gubbins for basic GUI components

Author:
  kevin

Field Summary
`protected GUIContext` | `container` The game container
`protected Input` | `input` The input we're responding to
`protected java.util.Set` | `listeners` Listeners for the component to notify

Constructor Summary
`AbstractComponent(GUIContext container)` Create a new component

Method Summary
`void` | `addListener(ComponentListener listener)` Add a component listener to be informed when the component sees fit.
`protected void` | `consumeEvent()` Consume the event currently being processed
`abstract int` | `getHeight()` Get the height of the component
`abstract int` | `getWidth()` Get the width of the component
`abstract int` | `getX()` Returns the position in the X coordinate
`abstract int` | `getY()` Returns the position in the Y coordinate
`boolean` | `hasFocus()` Check if this component currently has focus
`void` | `mouseReleased(int button, int x, int y)` Gives the focus to this component with a click of the mouse.
`protected void` | `notifyListeners()` Notify all the listeners.
`void` | `removeListener(ComponentListener listener)` Remove a component listener.
`abstract void` | `render(GUIContext container, Graphics g)` Render this component to the screen
`void` | `setFocus(boolean focus)` Indicate whether this component should be focused or not
`abstract void` | `setLocation(int x, int y)` Moves the component.

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, mouseDragged, mouseMoved, mousePressed, mouseWheelMoved, setAcceptingInput, setInput`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### container

    protected GUIContext container

  The game container

### listeners

    protected java.util.Set listeners

  Listeners for the component to notify

### input

    protected Input input

  The input we're responding to

Constructor Detail

### AbstractComponent

    public AbstractComponent(GUIContext container)

  Create a new component

  Parameters:
    `container` - The container displaying this component

Method Detail

### addListener

    public void addListener(ComponentListener listener)

  Add a component listener to be informed when the component sees fit. It will ignore listeners already added.

  Parameters:
    `listener` - listener

### removeListener

    public void removeListener(ComponentListener listener)

  Remove a component listener. It will ignore if the listener wasn't added.

  Parameters:
    `listener` - listener

### notifyListeners

    protected void notifyListeners()

  Notify all the listeners.

### render

    public abstract void render(GUIContext container,
                                Graphics g)
                         throws SlickException

  Render this component to the screen

  Parameters:
    `container` - The container displaying this component
    `g` - The graphics context used to render to the display
  Throws:
    `SlickException` - If there has been an error rendering the component

### setLocation

    public abstract void setLocation(int x,
                                     int y)

  Moves the component.

  Parameters:
    `x` - X coordinate
    `y` - Y coordinate

### getX

    public abstract int getX()

  Returns the position in the X coordinate

  Returns:
    x

### getY

    public abstract int getY()

  Returns the position in the Y coordinate

  Returns:
    y

### getWidth

    public abstract int getWidth()

  Get the width of the component

  Returns:
    The width of the component

### getHeight

    public abstract int getHeight()

  Get the height of the component

  Returns:
    The height of the component

### setFocus

    public void setFocus(boolean focus)

  Indicate whether this component should be focused or not

  Parameters:
    `focus` - if the component should be focused

### hasFocus

    public boolean hasFocus()

  Check if this component currently has focus

  Returns:
    if this field currently has focus

### consumeEvent

    protected void consumeEvent()

  Consume the event currently being processed

### mouseReleased

    public void mouseReleased(int button,
                              int x,
                              int y)

  Gives the focus to this component with a click of the mouse.

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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 New Dawn Software. All Rights Reserved.