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 TextField

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

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

    public class TextField

extends AbstractComponent

A single text field supporting text entry

Author:
  kevin

Field Summary
`protected int` | `x` The location in the X coordinate
`protected int` | `y` The location in the Y coordinate

Fields inherited from class org.newdawn.slick.gui.AbstractComponent
`container, input, listeners`

Constructor Summary
`TextField(GUIContext container, Font font, int x, int y, int width, int height)` Create a new text field
`TextField(GUIContext container, Font font, int x, int y, int width, int height, ComponentListener listener)` Create a new text field

Method Summary
`void` | `deactivate()` Deactivate the key input handling for this field
`protected void` | `doPaste(java.lang.String text)` Do the paste into the field, overrideable for custom behaviour
`protected void` | `doUndo(int oldCursorPos, java.lang.String oldText)` Do the undo of the paste, overrideable for custom behaviour
`int` | `getHeight()` Get the height of the component
`java.lang.String` | `getText()` Get the value in the text field
`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
`void` | `keyPressed(int key, char c)` Notification that a key was pressed
`protected void` | `recordOldPosition()` Record the old position and content
`void` | `render(GUIContext container, Graphics g)` Render this component to the screen
`void` | `setBackgroundColor(Color color)` Set the background color.
`void` | `setBorderColor(Color color)` Set the border color.
`void` | `setConsumeEvents(boolean consume)` Indicate if the input events should be consumed by this field
`void` | `setCursorPos(int pos)` Set the position of the cursor
`void` | `setCursorVisible(boolean visibleCursor)` Indicate whether the mouse cursor should be visible or not
`void` | `setFocus(boolean focus)` Indicate whether this component should be focused or not
`void` | `setLocation(int x, int y)` Moves the component.
`void` | `setMaxLength(int length)` Set the length of the allowed input
`void` | `setText(java.lang.String value)` Set the value to be displayed in the text field
`void` | `setTextColor(Color color)` Set the text color.

Methods inherited from class org.newdawn.slick.gui.AbstractComponent
`addListener, consumeEvent, hasFocus, mouseReleased, notifyListeners, removeListener`

Methods inherited from class org.newdawn.slick.util.InputAdapter
`controllerButtonPressed, controllerButtonReleased, controllerDownPressed, controllerDownReleased, controllerLeftPressed, controllerLeftReleased, controllerRightPressed, controllerRightReleased, controllerUpPressed, controllerUpReleased, inputEnded, inputStarted, isAcceptingInput, 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

### x

    protected int x

  The location in the X coordinate

### y

    protected int y

  The location in the Y coordinate

Constructor Detail

### TextField

    public TextField(GUIContext container,
                     Font font,
                     int x,
                     int y,
                     int width,
                     int height,
                     ComponentListener listener)

  Create a new text field

  Parameters:
    `container` - The container rendering this field
    `font` - The font to use in the text field
    `x` - The x coordinate of the top left corner of the text field
    `y` - The y coordinate of the top left corner of the text field
    `width` - The width of the text field
    `height` - The height of the text field
    `listener` - The listener to add to the text field

### TextField

    public TextField(GUIContext container,
                     Font font,
                     int x,
                     int y,
                     int width,
                     int height)

  Create a new text field

  Parameters:
    `container` - The container rendering this field
    `font` - The font to use in the text field
    `x` - The x coordinate of the top left corner of the text field
    `y` - The y coordinate of the top left corner of the text field
    `width` - The width of the text field
    `height` - The height of the text field

Method Detail

### setConsumeEvents

    public void setConsumeEvents(boolean consume)

  Indicate if the input events should be consumed by this field

  Parameters:
    `consume` - True if events should be consumed by this field

### deactivate

    public void deactivate()

  Deactivate the key input handling for this field

### setLocation

    public void setLocation(int x,
                            int y)

  Moves the component.

  Specified by:
    `setLocation` in class `AbstractComponent`
  Parameters:
    `x` - X coordinate
    `y` - Y coordinate

### 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

### getWidth

    public int getWidth()

  Get the width of the component

  Specified by:
    `getWidth` in class `AbstractComponent`
  Returns:
    The width of the component

### getHeight

    public int getHeight()

  Get the height of the component

  Specified by:
    `getHeight` in class `AbstractComponent`
  Returns:
    The height of the component

### setBackgroundColor

    public void setBackgroundColor(Color color)

  Set the background color. Set to null to disable the background

  Parameters:
    `color` - The color to use for the background

### setBorderColor

    public void setBorderColor(Color color)

  Set the border color. Set to null to disable the border

  Parameters:
    `color` - The color to use for the border

### setTextColor

    public void setTextColor(Color color)

  Set the text color.

  Parameters:
    `color` - The color to use for the text

### 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)`

### getText

    public java.lang.String getText()

  Get the value in the text field

  Returns:
    The value in the text field

### setText

    public void setText(java.lang.String value)

  Set the value to be displayed in the text field

  Parameters:
    `value` - The value to be displayed in the text field

### setCursorPos

    public void setCursorPos(int pos)

  Set the position of the cursor

  Parameters:
    `pos` - The new position of the cursor

### setCursorVisible

    public void setCursorVisible(boolean visibleCursor)

  Indicate whether the mouse cursor should be visible or not

  Parameters:
    `visibleCursor` - True if the mouse cursor should be visible

### setMaxLength

    public void setMaxLength(int length)

  Set the length of the allowed input

  Parameters:
    `length` - The length of the allowed input

### doPaste

    protected void doPaste(java.lang.String text)

  Do the paste into the field, overrideable for custom behaviour

  Parameters:
    `text` - The text to be pasted in

### recordOldPosition

    protected void recordOldPosition()

  Record the old position and content

### doUndo

    protected void doUndo(int oldCursorPos,
                          java.lang.String oldText)

  Do the undo of the paste, overrideable for custom behaviour

  Parameters:
    `oldCursorPos` - before the paste
    `oldText` - The text before the last paste

### keyPressed

    public void keyPressed(int key,
                           char c)

  Description copied from interface: `KeyListener`
  Notification that a key was pressed

  Specified by:
    `keyPressed` in interface `KeyListener`
  Overrides:
    `keyPressed` in class `InputAdapter`
  Parameters:
    `key` - The key code that was pressed (@see org.newdawn.slick.Input)
    `c` - The character of the key that was pressed
  See Also:
    `InputAdapter.keyPressed(int, char)`

### setFocus

    public void setFocus(boolean focus)

  Description copied from class: `AbstractComponent`
  Indicate whether this component should be focused or not

  Overrides:
    `setFocus` in class `AbstractComponent`
  Parameters:
    `focus` - if the component should be focused
  See Also:
    `AbstractComponent.setFocus(boolean)`

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.