Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: TextInputControl

[118:7] extends: Control

TextInputControl is the abstract base class for all JavaFX text input controls, including TextField, TextArea, and PasswordField. It provides the core API for reading and writing text content, managing text selection, and responding to text change events. The class defines the CSS properties that govern font, text color, prompt text, and selection highlight appearance shared by every text input control. A readonly pseudo-class is applied automatically when the control's editable property is false. The tables below list every CSS property available to TextInputControl, organized by the class level where each property is defined. Properties defined at a higher level are inherited by all subclasses below it.

CSS Pseudo-classes -- TextInputControl

Pseudo-class Description
readonly Applies when the control is not editable (editable is false).

CSS Properties -- TextInputControl

Property Values Default Description
-fx-font <font> null (inherits) Font used to render the input text.
-fx-text-fill <paint> black Color of the input text.
-fx-prompt-text-fill <paint> gray Color of the prompt (placeholder) text shown when the field is empty.
-fx-highlight-fill <paint> dodgerblue Background fill color of selected text.
-fx-highlight-text-fill <paint> white Text color of selected text.
-fx-display-caret true | false true When true, the text insertion caret is displayed.

CSS Properties -- Control

Property Values Default Description
-fx-skin <string> null Fully qualified class name of the Skin to use for rendering this control.
-fx-focus-traversable true | false true When true, the control participates in focus traversal via the keyboard Tab key.

CSS Properties -- Region

Background fills

Property Values Default Description
-fx-background-color <paint> [, <paint>]* transparent One or more paint values for background fill layers, rendered back to front.
-fx-background-insets <size> or <t> <r> <b> <l> [, ...]* 0 0 0 0 Insets from the region edges for each background fill layer.
-fx-background-radius <size> [/ <size>]* [, ...]* 0 0 0 0 Corner radii for each background fill layer.

Background images

Property Values Default Description
-fx-background-image <uri> [, <uri>]* null One or more image URIs for background image layers.
-fx-background-position <bg-position> [, ...]* 0% 0% Position of each background image within the region. Accepts keywords or size values.
-fx-background-repeat <repeat-style> [, ...]* repeat repeat Tiling behavior for each background image. Values: repeat, no-repeat, round, space applied per axis.
-fx-background-size <bg-size> [, ...]* auto auto Dimensions for each background image. Supports cover, contain, stretch, or explicit sizes.

Stroked borders

Property Values Default Description
-fx-border-color <paint> or <t> <r> <b> <l> [, ...]* null Paint colors for the border stroke layers.
-fx-border-insets <size> or <t> <r> <b> <l> [, ...]* null Insets from region edges for each border layer.
-fx-border-radius <size> [, ...]* null Corner radii for border stroke layers.
-fx-border-style <border-style> [, ...]* null Border line style (solid, dotted, dashed) plus phase and line cap/join options per layer.
-fx-border-width <size> or <t> <r> <b> <l> [, ...]* null Thickness of each border stroke layer, per side.

Border images

Property Values Default Description
-fx-border-image-source <uri> [, <uri>]* null Image URIs used to paint the border.
-fx-border-image-insets <size> or <t> <r> <b> <l> [, ...]* 0 0 0 0 Insets for each border image layer.
-fx-border-image-repeat <repeat-style> [, ...]* repeat repeat Tiling behavior for each border image.
-fx-border-image-slice <size> or <t> <r> <b> <l> [fill] [, ...]* 100% Divides each border image into nine regions. Adding fill preserves the center region.
-fx-border-image-width <size> or <t> <r> <b> <l> [, ...]* 1 1 1 1 Width of each border image slice per side.

Other Region properties

Property Values Default Description
-fx-padding <size> or <t> <r> <b> <l> 0 0 0 0 Interior padding between the region border and its content.
-fx-shape <string> null SVG path string that defines a custom clip shape for the region.
-fx-scale-shape true | false true When true, the shape is scaled to fit the region.
-fx-position-shape true | false true When true, the shape is centered within the region.
-fx-snap-to-pixel true | false true When true, positions and sizes are rounded to whole pixel boundaries.
-fx-min-width <size> -1 Minimum width. -1 uses the computed minimum.
-fx-pref-width <size> -1 Preferred width. -1 uses the computed preferred.
-fx-max-width <size> -1 Maximum width. -1 uses the computed maximum.
-fx-min-height <size> -1 Minimum height. -1 uses the computed minimum.
-fx-pref-height <size> -1 Preferred height. -1 uses the computed preferred.
-fx-max-height <size> -1 Maximum height. -1 uses the computed maximum.

CSS Properties -- Node

Property Values Default Description
-fx-blend-mode add | blue | color-burn | color-dodge | darken | difference | exclusion | green | hard-light | lighten | multiply | overlay | red | screen | soft-light | src-atop | src-in | src-out | src-over null Blend mode used when compositing this node with nodes beneath it.
-fx-cursor null | crosshair | default | hand | move | e-resize | h-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | v-resize | text | wait | <url> null (inherits) Mouse cursor shape shown when the pointer is over this node. Inherits from parent by default.
-fx-effect <effect> null A visual effect (e.g. DropShadow, InnerShadow) applied to the rendered node.
-fx-focus-traversable true | false false Whether this node participates in focus traversal. Overridden to true by Control.
-fx-view-order <number> 0 Adjusts rendering and hit-test order within the parent without changing the scene graph order.
-fx-opacity <number> [0.0 - 1.0] 1 Opacity of the node. 0 is fully transparent, 1 is fully opaque.
-fx-rotate <number> 0 Rotation angle in degrees applied around the node's center point. Positive values are clockwise.
-fx-scale-x <number> 1 Scale factor along the X axis about the node's center.
-fx-scale-y <number> 1 Scale factor along the Y axis about the node's center.
-fx-scale-z <number> 1 Scale factor along the Z axis about the node's center.
-fx-translate-x <number> 0 Translation offset along the X axis in pixels.
-fx-translate-y <number> 0 Translation offset along the Y axis in pixels.
-fx-translate-z <number> 0 Translation offset along the Z axis in pixels.
visibility visible | hidden | collapse | inherit visible Controls whether the node is rendered and participates in layout. collapse removes it from layout; hidden keeps the space.
-fx-managed true | false true When false, the parent layout does not manage this node's position or size.

Methods

  • setText (string Text)

    Sets the text content of the text input control.

    • @p Text is a string to set as the current content of the control.
    • @r this object for chaining
  • getText ()

    Retrieves the current text content of the text input control.

    • @r A string with the current text in the control.
  • onChange (callback OnChange)

    Sets a callback function that triggers when the text content changes.

    • @p OnChange The callback function for handling text change events.
    • @r this object for chaining
  • fontProperty ()

    Returns the font ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • setFont (object FontObj)

    Sets the font used to render the input text.

    • @p FontObj is a Font wrapper object.
    • @r this object for chaining
  • getFont ()

    Returns the current font used to render text.

    • @r An AJO around a javafx.scene.text.Font.
  • promptTextProperty ()

    Returns the promptText StringProperty for binding.

    • @r An AJO around the StringProperty.
  • getPromptText ()

    Returns the placeholder prompt text shown when the field is empty.

    • @r A string with the prompt text.
  • setPromptText (string Text)

    Sets the placeholder prompt text shown when the field is empty.

    • @p Text is a string with the prompt to display.
    • @r this object for chaining
  • textFormatterProperty ()

    Returns the textFormatter ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • getTextFormatter ()

    Returns the current TextFormatter that governs text input.

    • @r An AJO around the TextFormatter, or null.
  • setTextFormatter (object Formatter)

    Sets the TextFormatter that governs text input filtering and value conversion.

    • @p Formatter is an AJO around a javafx.scene.control.TextFormatter.
    • @r this object for chaining
  • textProperty ()

    Returns the text StringProperty for binding.

    • @r An AJO around the StringProperty.
  • getLength ()

    Returns the length of the text content in characters.

    • @r An int with the number of characters.
  • lengthProperty ()

    Returns the length ReadOnlyIntegerProperty for binding.

    • @r An AJO around the ReadOnlyIntegerProperty.
  • isEditable ()

    Returns whether the control is editable.

    • @r A bool with true if editable.
  • setEditable (bool Value)

    Sets whether the control is editable.

    • @p Value is a bool with true to allow editing.
    • @r this object for chaining
  • editableProperty ()

    Returns the editable BooleanProperty for binding.

    • @r An AJO around the BooleanProperty.
  • getSelection ()

    Returns the current selection as an IndexRange.

    • @r An AJO around the javafx.scene.control.IndexRange.
  • selectionProperty ()

    Returns the selection ReadOnlyObjectProperty for binding.

    • @r An AJO around the ReadOnlyObjectProperty.
  • getSelectedText ()

    Returns the currently selected text content.

    • @r A string with the selected text.
  • selectedTextProperty ()

    Returns the selectedText ReadOnlyStringProperty for binding.

    • @r An AJO around the ReadOnlyStringProperty.
  • getAnchor ()

    Returns the anchor character position of the current selection.

    • @r An int with the anchor position.
  • anchorProperty ()

    Returns the anchor ReadOnlyIntegerProperty for binding.

    • @r An AJO around the ReadOnlyIntegerProperty.
  • getCaretPosition ()

    Returns the current caret character position.

    • @r An int with the caret position.
  • caretPositionProperty ()

    Returns the caretPosition ReadOnlyIntegerProperty for binding.

    • @r An AJO around the ReadOnlyIntegerProperty.
  • isUndoable ()

    Returns whether the most recent operation can be undone.

    • @r A bool with true if an undo is available.
  • undoableProperty ()

    Returns the undoable ReadOnlyBooleanProperty for binding.

    • @r An AJO around the ReadOnlyBooleanProperty.
  • isRedoable ()

    Returns whether the most recent undo can be redone.

    • @r A bool with true if a redo is available.
  • redoableProperty ()

    Returns the redoable ReadOnlyBooleanProperty for binding.

    • @r An AJO around the ReadOnlyBooleanProperty.
  • appendText (string Text)

    Appends the given text to the end of the current content.

    • @p Text is a string to append.
    • @r this object for chaining
  • insertText (int Index, string Text)

    Inserts text at the specified character index.

    • @p Index is an int with the insertion position.
    • @p Text is a string to insert.
    • @r this object for chaining
  • deleteText (int Start, int End)

    Deletes the character range starting at Start and ending at End.

    • @p Start is an int with the start character index.
    • @p End is an int with the end character index (exclusive).
    • @r this object for chaining
  • replaceText (int Start, int End, string Text)

    Replaces the character range with new text.

    • @p Start is an int with the start character index.
    • @p End is an int with the end character index (exclusive).
    • @p Text is a string with the replacement content.
    • @r this object for chaining
  • cut ()

    Cuts the current selection to the clipboard.

    • @r this object for chaining
  • copy ()

    Copies the current selection to the clipboard.

    • @r this object for chaining
  • paste ()

    Pastes the clipboard contents at the caret position.

    • @r this object for chaining
  • selectBackward ()

    Extends the selection one character backward.

    • @r this object for chaining
  • selectForward ()

    Extends the selection one character forward.

    • @r this object for chaining
  • previousWord ()

    Moves the caret to the start of the previous word.

    • @r this object for chaining
  • nextWord ()

    Moves the caret to the start of the next word.

    • @r this object for chaining
  • endOfNextWord ()

    Moves the caret to the end of the next word.

    • @r this object for chaining
  • selectPreviousWord ()

    Extends the selection to the start of the previous word.

    • @r this object for chaining
  • selectNextWord ()

    Extends the selection to the start of the next word.

    • @r this object for chaining
  • selectEndOfNextWord ()

    Extends the selection to the end of the next word.

    • @r this object for chaining
  • selectAll ()

    Selects all of the text content.

    • @r this object for chaining
  • home ()

    Moves the caret to the start of the content.

    • @r this object for chaining
  • end ()

    Moves the caret to the end of the content.

    • @r this object for chaining
  • selectHome ()

    Extends the selection to the start of the content.

    • @r this object for chaining
  • selectEnd ()

    Extends the selection to the end of the content.

    • @r this object for chaining
  • deletePreviousChar ()

    Deletes the character before the caret.

    • @r A bool with true if a character was deleted.
  • deleteNextChar ()

    Deletes the character after the caret.

    • @r A bool with true if a character was deleted.
  • forward ()

    Moves the caret forward one character.

    • @r this object for chaining
  • backward ()

    Moves the caret backward one character.

    • @r this object for chaining
  • positionCaret (int Pos)

    Moves the caret to the given character position without selecting.

    • @p Pos is an int with the new caret position.
    • @r this object for chaining
  • selectPositionCaret (int Pos)

    Moves the caret to the given position and extends the selection.

    • @p Pos is an int with the new caret position.
    • @r this object for chaining
  • selectRange (int Anchor, int Caret)

    Selects the character range from Anchor to Caret.

    • @p Anchor is an int with the anchor position.
    • @p Caret is an int with the caret position.
    • @r this object for chaining
  • extendSelection (int Pos)

    Extends the selection from the current anchor to the given position.

    • @p Pos is an int with the new caret position.
    • @r this object for chaining
  • clear ()

    Clears the entire text content.

    • @r this object for chaining
  • deselect ()

    Clears the current selection without changing the caret position.

    • @r this object for chaining
  • replaceSelection (string Text)

    Replaces the current selection with the given text.

    • @p Text is a string with the replacement content.
    • @r this object for chaining
  • undo ()

    Undoes the most recent text edit.

    • @r this object for chaining
  • redo ()

    Redoes the most recently undone text edit.

    • @r this object for chaining
  • commitValue ()

    Commits the current value through any active text formatter.

    • @r this object for chaining
  • cancelEdit ()

    Cancels any in-progress edit and reverts to the last committed value.

    • @r this object for chaining
  • getControlCssMetaData ()

    Returns the CSS metadata for this control's styleable properties.

    • @r A list of CssMetaData entries.