|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.newdawn.slick.util.InputAdapter
org.newdawn.slick.gui.AbstractComponent
org.newdawn.slick.gui.TextField
public class TextField
A single text field supporting text entry
| 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 |
|---|
protected int x
protected int y
| Constructor Detail |
|---|
public TextField(GUIContext container,
Font font,
int x,
int y,
int width,
int height,
ComponentListener listener)
container - The container rendering this fieldfont - The font to use in the text fieldx - The x coordinate of the top left corner of the text fieldy - The y coordinate of the top left corner of the text fieldwidth - The width of the text fieldheight - The height of the text fieldlistener - The listener to add to the text field
public TextField(GUIContext container,
Font font,
int x,
int y,
int width,
int height)
container - The container rendering this fieldfont - The font to use in the text fieldx - The x coordinate of the top left corner of the text fieldy - The y coordinate of the top left corner of the text fieldwidth - The width of the text fieldheight - The height of the text field| Method Detail |
|---|
public void setConsumeEvents(boolean consume)
consume - True if events should be consumed by this fieldpublic void deactivate()
public void setLocation(int x,
int y)
setLocation in class AbstractComponentx - X coordinatey - Y coordinatepublic int getX()
getX in class AbstractComponentpublic int getY()
getY in class AbstractComponentpublic int getWidth()
getWidth in class AbstractComponentpublic int getHeight()
getHeight in class AbstractComponentpublic void setBackgroundColor(Color color)
color - The color to use for the backgroundpublic void setBorderColor(Color color)
color - The color to use for the borderpublic void setTextColor(Color color)
color - The color to use for the text
public void render(GUIContext container,
Graphics g)
AbstractComponent
render in class AbstractComponentcontainer - The container displaying this componentg - The graphics context used to render to the displayAbstractComponent.render(org.newdawn.slick.gui.GUIContext,
org.newdawn.slick.Graphics)public java.lang.String getText()
public void setText(java.lang.String value)
value - The value to be displayed in the text fieldpublic void setCursorPos(int pos)
pos - The new position of the cursorpublic void setCursorVisible(boolean visibleCursor)
visibleCursor - True if the mouse cursor should be visiblepublic void setMaxLength(int length)
length - The length of the allowed inputprotected void doPaste(java.lang.String text)
text - The text to be pasted inprotected void recordOldPosition()
protected void doUndo(int oldCursorPos,
java.lang.String oldText)
oldCursorPos - before the pasteoldText - The text before the last paste
public void keyPressed(int key,
char c)
KeyListener
keyPressed in interface KeyListenerkeyPressed in class InputAdapterkey - The key code that was pressed (@see org.newdawn.slick.Input)c - The character of the key that was pressedInputAdapter.keyPressed(int, char)public void setFocus(boolean focus)
AbstractComponent
setFocus in class AbstractComponentfocus - if the component should be focusedAbstractComponent.setFocus(boolean)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||