Package de.gurkenlabs.litiengine.gui
Class TextFieldComponent
java.lang.Object
de.gurkenlabs.litiengine.gui.GuiComponent
de.gurkenlabs.litiengine.gui.ImageComponent
de.gurkenlabs.litiengine.gui.TextFieldComponent
- All Implemented Interfaces:
IRenderable
,Tweenable
,java.awt.event.MouseListener
,java.awt.event.MouseMotionListener
,java.awt.event.MouseWheelListener
,java.util.EventListener
- Direct Known Subclasses:
NumberAdjuster
public class TextFieldComponent
extends ImageComponent
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DOUBLE_FORMAT
static java.lang.String
INTEGER_FORMAT
Fields inherited from class de.gurkenlabs.litiengine.gui.ImageComponent
BACKGROUND_DISABLED_INDEX, BACKGROUND_HOVER_INDEX, BACKGROUND_INDEX, BACKGROUND_PRESSED_INDEX
Constructor Summary
Constructors Constructor Description TextFieldComponent(double x, double y, double width, double height, java.lang.String text)
Method Summary
Modifier and Type Method Description java.lang.String
getFormat()
int
getMaxLength()
java.lang.String
getText()
Gets the entire Text associated with this GuiComponent.void
handleTypedKey(java.awt.event.KeyEvent event)
void
onChangeConfirmed(java.util.function.Consumer<java.lang.String> cons)
void
render(java.awt.Graphics2D g)
Renders the visual contents of this instance onto the provided graphics context.void
setFormat(java.lang.String format)
void
setMaxLength(int maxLength)
void
setText(java.lang.String text)
Sets the text.Methods inherited from class de.gurkenlabs.litiengine.gui.ImageComponent
getBackground, getImage, getImageAlign, getImageScaleMode, getImageValign, getSpritesheet, rescaleImage, setHeight, setImage, setImageAlign, setImageScaleMode, setImageValign, setSpriteSheet, setWidth
Methods inherited from class de.gurkenlabs.litiengine.gui.GuiComponent
drawTextShadow, getAppearance, getAppearanceDisabled, getAppearanceHovered, getBoundingBox, getClickConsumer, getComponentId, getComponents, getCurrentAppearance, getFont, getHeight, getHoverConsumer, getHoverSound, getLocation, getMouseDraggedConsumer, getMouseEnterConsumer, getMouseLeaveConsumer, getMouseMovedConsumer, getMousePressedConsumer, getMouseReleasedConsumer, getMouseWheelConsumer, getName, getShape, getTag, getTextAlign, getTextAngle, getTextShadowColor, getTextShadowStroke, getTextToRender, getTextValign, getTextX, getTextY, getTweenValues, getWidth, getX, getY, hasAutomaticLineBreaks, hasTextAntialiasing, initializeComponents, isEnabled, isForwardMouseEvents, isHovered, isPressed, isSelected, isSuspended, isVisible, mouseClicked, mouseDragged, mouseEntered, mouseEventShouldBeForwarded, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, onClicked, onHovered, onMouseDragged, onMouseEnter, onMouseLeave, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheelScrolled, onTextChanged, prepare, setAutomaticLineBreaks, setDimension, setEnabled, setFont, setFontSize, setForwardMouseEvents, setHovered, setHoverSound, setLocation, setLocation, setName, setSelected, setTag, setTextAlign, setTextAngle, setTextAntialiasing, setTextShadow, setTextShadowColor, setTextShadowStroke, setTextValign, setTextX, setTextY, setTweenValues, setVisible, setX, setY, suspend, toggleSelection, toggleSuspension
Field Details
DOUBLE_FORMAT
public static final java.lang.String DOUBLE_FORMAT- See Also:
- Constant Field Values
INTEGER_FORMAT
public static final java.lang.String INTEGER_FORMAT- See Also:
- Constant Field Values
Constructor Details
TextFieldComponent
public TextFieldComponent(double x, double y, double width, double height, java.lang.String text)
Method Details
getFormat
public java.lang.String getFormat()getMaxLength
public int getMaxLength()getText
public java.lang.String getText()Description copied from class:GuiComponent
Gets the entire Text associated with this GuiComponent. Parts of the Text may get cropped and can therefore be invisible. To retrieve only the visible part of the text, useGuiComponent.getTextToRender(Graphics2D g)
.- Overrides:
getText
in classGuiComponent
- Returns:
- the entire text on this GuiComponent
handleTypedKey
public void handleTypedKey(java.awt.event.KeyEvent event)onChangeConfirmed
public void onChangeConfirmed(java.util.function.Consumer<java.lang.String> cons)render
public void render(java.awt.Graphics2D g)Description copied from interface:IRenderable
Renders the visual contents of this instance onto the provided graphics context.If an
Entity
implements this interface, this method will be called right after the entity was rendered from the environment. Allowing for a custom rendering mechanism.This interface can be implemented in general by anything that should be rendered to the game's screen.
- Specified by:
render
in interfaceIRenderable
- Overrides:
render
in classImageComponent
- Parameters:
g
- The current graphics object onto which this instance will render its visual contents.- See Also:
RenderEngine.renderEntity(Graphics2D, de.gurkenlabs.litiengine.entities.IEntity)
setFormat
public void setFormat(java.lang.String format)setMaxLength
public void setMaxLength(int maxLength)setText
public void setText(java.lang.String text)Description copied from class:GuiComponent
Sets the text.- Overrides:
setText
in classGuiComponent
- Parameters:
text
- the new text