Spec-Zone.ru › OpenJavaFX 21

Class TextInputControl

java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.control.Control
javafx.scene.control.TextInputControl
All Implemented Interfaces:
Styleable, EventTarget, Skinnable
Direct Known Subclasses:
TextArea, TextField
@DefaultProperty("text") public abstract class TextInputControl extends Control
Abstract base class for text input controls.
Since:
JavaFX 2.0

Property Summary

Type Property Description
final ReadOnlyIntegerProperty anchor
The anchor of the text selection.
final ReadOnlyIntegerProperty caretPosition
The current position of the caret within the text.
final BooleanProperty editable
Indicates whether this TextInputControl can be edited by the user.
final ObjectProperty<Font> font
The default font to use for text in the TextInputControl.
final ReadOnlyIntegerProperty length
The number of characters in the text input.
final StringProperty promptText
The prompt text to display in the TextInputControl.
final ReadOnlyBooleanProperty redoable
The property describes if it's currently possible to redo the latest change of the content that was undone.
final ReadOnlyStringProperty selectedText
Defines the characters in the TextInputControl which are selected
final ReadOnlyObjectProperty<IndexRange> selection
The current selection.
final ObjectProperty<TextFormatter<?>> textFormatter
The property contains currently attached TextFormatter.
final StringProperty text
The textual content of this TextInputControl.
final ReadOnlyBooleanProperty undoable
The property describes if it's currently possible to undo the latest change of the content that was done.

Properties declared in class javafx.scene.control.Control

contextMenu, skin, tooltip

Properties declared in class javafx.scene.layout.Region

background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width

Properties declared in class javafx.scene.Parent

needsLayout

Properties declared in class javafx.scene.Node

accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible

Nested Class Summary

Modifier and Type Class Description
protected static interface  TextInputControl.Content
Interface representing a text input's content.

Field Summary

Fields declared in class javafx.scene.layout.Region

USE_COMPUTED_SIZE, USE_PREF_SIZE

Fields declared in class javafx.scene.Node

BASELINE_OFFSET_SAME_AS_HEIGHT

Constructor Summary

TextInputControl(TextInputControl.Content content)
Modifier Constructor Description
protected
Creates a new TextInputControl.

Method Summary

Modifier and Type Method Description
final ReadOnlyIntegerProperty anchorProperty()
The anchor of the text selection.
void appendText(String text)
Appends a sequence of characters to the content.
void backward()
Moves the caret position backward.
final void cancelEdit()
If the field is currently being edited, this call will set text to the last commited value.
final ReadOnlyIntegerProperty caretPositionProperty()
The current position of the caret within the text.
void clear()
Clears the text.
final void commitValue()
Commit the current text and convert it to a value.
void copy()
Transfers the currently selected range in the text to the clipboard, leaving the current selection.
void cut()
Transfers the currently selected range in the text to the clipboard, removing the current selection.
boolean deleteNextChar()
Deletes the character that follows the current caret position from the text if there is no selection, or deletes the selection if there is one.
boolean deletePreviousChar()
Deletes the character that precedes the current caret position from the text if there is no selection, or deletes the selection if there is one.
void deleteText(int start, int end)
Removes a range of characters from the content.
void deleteText(IndexRange range)
Removes a range of characters from the content.
void deselect()
Clears the selection.
final BooleanProperty editableProperty()
Indicates whether this TextInputControl can be edited by the user.
void end()
Moves the caret to after the last char of the text.
void endOfNextWord()
Moves the caret to the end of the next word.
void extendSelection(int pos)
This function will extend the selection to include the specified pos.
final ObjectProperty<Font> fontProperty()
The default font to use for text in the TextInputControl.
void forward()
Moves the caret position forward.
final int getAnchor()
Gets the value of the anchor property.
final int getCaretPosition()
Gets the value of the caretPosition property.
static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
protected final TextInputControl.Content getContent()
Returns the text input's content model.
List<CssMetaData<? extends Styleable,?>> getControlCssMetaData()
Gets the unmodifiable list of the control's CSS-styleable properties.
final Font getFont()
Gets the value of the font property.
final int getLength()
Gets the value of the length property.
final String getPromptText()
Gets the value of the promptText property.
final String getSelectedText()
Gets the value of the selectedText property.
final IndexRange getSelection()
Gets the value of the selection property.
final String getText()
Gets the value of the text property.
String getText(int start, int end)
Returns a subset of the text input's content.
final TextFormatter<?> getTextFormatter()
Gets the value of the textFormatter property.
void home()
Moves the caret to before the first char of the text.
void insertText(int index, String text)
Inserts a sequence of characters into the content.
final boolean isEditable()
Gets the value of the editable property.
final boolean isRedoable()
Gets the value of the redoable property.
final boolean isUndoable()
Gets the value of the undoable property.
final ReadOnlyIntegerProperty lengthProperty()
The number of characters in the text input.
void nextWord()
Moves the caret to the beginning of next word.
void paste()
Transfers the contents in the clipboard into this text, replacing the current selection.
void positionCaret(int pos)
Positions the caret to the position indicated by pos.
void previousWord()
Moves the caret to the beginning of previous word.
final StringProperty promptTextProperty()
The prompt text to display in the TextInputControl.
final void redo()
If possible, redoes the last undone modification.
final ReadOnlyBooleanProperty redoableProperty()
The property describes if it's currently possible to redo the latest change of the content that was undone.
void replaceSelection(String replacement)
Replaces the selection with the given replacement String.
void replaceText(int start, int end, String text)
Replaces a range of characters with the given text.
void replaceText(IndexRange range, String text)
Replaces a range of characters with the given text.
void selectAll()
Selects all text in the text input.
void selectBackward()
Moves the selection backward one char in the text.
final ReadOnlyStringProperty selectedTextProperty()
Defines the characters in the TextInputControl which are selected
void selectEnd()
Moves the caret to after the last char of text.
void selectEndOfNextWord()
Moves the caret to the end of the next word.
void selectForward()
Moves the selection forward one char in the text.
void selectHome()
Moves the caret to before the first char of text.
final ReadOnlyObjectProperty<IndexRange> selectionProperty()
The current selection.
void selectNextWord()
Moves the caret to the beginning of next word.
void selectPositionCaret(int pos)
Positions the caret to the position indicated by pos and extends the selection, if there is one.
void selectPreviousWord()
Moves the caret to the beginning of previous word.
void selectRange(int anchor, int caretPosition)
Positions the anchor and caretPosition explicitly.
final void setEditable(boolean value)
Sets the value of the editable property.
final void setFont(Font value)
Sets the value of the font property.
final void setPromptText(String value)
Sets the value of the promptText property.
final void setText(String value)
Sets the value of the text property.
final void setTextFormatter(TextFormatter<?> value)
Sets the value of the textFormatter property.
final ObjectProperty<TextFormatter<?>> textFormatterProperty()
The property contains currently attached TextFormatter.
final StringProperty textProperty()
The textual content of this TextInputControl.
final void undo()
If possible, undoes the last modification.
final ReadOnlyBooleanProperty undoableProperty()
The property describes if it's currently possible to undo the latest change of the content that was done.

Methods declared in class javafx.scene.control.Control

computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, contextMenuProperty, createDefaultSkin, getContextMenu, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, setContextMenu, setSkin, setTooltip, skinProperty, tooltipProperty

Methods declared in class javafx.scene.layout.Region

backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computePrefHeight, computePrefWidth, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty

Methods declared in class javafx.scene.Parent

getBaselineOffset, getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, layoutChildren, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBounds

Methods declared in class javafx.scene.Node

accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isFocusVisible, isFocusWithin, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookup, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, queryAccessibleAttribute, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty

Methods declared in class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Methods declared in interface javafx.css.Styleable

getStyleableNode

Property Details

font

public final ObjectProperty<Font> fontProperty
The default font to use for text in the TextInputControl. If the TextInputControl's text is rich text then this font may or may not be used depending on the font information embedded in the rich text, but in any case where a default font is required, this font will be used.
Since:
JavaFX 8.0
See Also:
  • getFont()
  • setFont(Font)
  • fontProperty()

promptText

public final StringProperty promptTextProperty
The prompt text to display in the TextInputControl. If set to null or an empty string, no prompt text is displayed.
Default value:
An empty String
Since:
JavaFX 2.2
See Also:
  • getPromptText()
  • setPromptText(String)
  • promptTextProperty()

textFormatter

public final ObjectProperty<TextFormatter<?>> textFormatterProperty
The property contains currently attached TextFormatter. Since the value is part of the Formatter, changing the TextFormatter will update the text based on the new textFormatter.
Default value:
null
Since:
JavaFX 8u40
See Also:
  • getTextFormatter()
  • setTextFormatter(TextFormatter)
  • textFormatterProperty()

text

public final StringProperty textProperty
The textual content of this TextInputControl.
See Also:
  • getText()
  • setText(String)
  • textProperty()

length

public final ReadOnlyIntegerProperty lengthProperty
The number of characters in the text input.
See Also:
  • getLength()
  • lengthProperty()

editable

public final BooleanProperty editableProperty
Indicates whether this TextInputControl can be edited by the user.
See Also:
  • isEditable()
  • setEditable(boolean)
  • editableProperty()

selection

public final ReadOnlyObjectProperty<IndexRange> selectionProperty
The current selection.
See Also:
  • getSelection()
  • selectionProperty()

selectedText

public final ReadOnlyStringProperty selectedTextProperty
Defines the characters in the TextInputControl which are selected
See Also:
  • getSelectedText()
  • selectedTextProperty()

anchor

public final ReadOnlyIntegerProperty anchorProperty
The anchor of the text selection. The anchor and caretPosition make up the selection range. Selection must always be specified in terms of begin <= end, but anchor may be less than, equal to, or greater than the caretPosition. Depending on how the user selects text, the anchor might represent the lower or upper bound of the selection.
See Also:
  • getAnchor()
  • anchorProperty()

caretPosition

public final ReadOnlyIntegerProperty caretPositionProperty
The current position of the caret within the text. The anchor and caretPosition make up the selection range. Selection must always be specified in terms of begin <= end, but anchor may be less than, equal to, or greater than the caretPosition. Depending on how the user selects text, the caretPosition might represent the lower or upper bound of the selection.
See Also:
  • getCaretPosition()
  • caretPositionProperty()

undoable

public final ReadOnlyBooleanProperty undoableProperty
The property describes if it's currently possible to undo the latest change of the content that was done.
Default value:
false
Since:
JavaFX 8u40
See Also:
  • isUndoable()
  • undoableProperty()

redoable

public final ReadOnlyBooleanProperty redoableProperty
The property describes if it's currently possible to redo the latest change of the content that was undone.
Default value:
false
Since:
JavaFX 8u40
See Also:
  • isRedoable()
  • redoableProperty()

Constructor Details

TextInputControl

protected TextInputControl(TextInputControl.Content content)
Creates a new TextInputControl. The content is an immutable property and must be specified (as non-null) at the time of construction.
Parameters:
content - a non-null implementation of Content.

Method Details

fontProperty

public final ObjectProperty<Font> fontProperty()
The default font to use for text in the TextInputControl. If the TextInputControl's text is rich text then this font may or may not be used depending on the font information embedded in the rich text, but in any case where a default font is required, this font will be used.
Returns:
the font property
Since:
JavaFX 8.0
See Also:
  • getFont()
  • setFont(Font)

setFont

public final void setFont(Font value)
Sets the value of the font property.
Property description:
The default font to use for text in the TextInputControl. If the TextInputControl's text is rich text then this font may or may not be used depending on the font information embedded in the rich text, but in any case where a default font is required, this font will be used.
Parameters:
value - the value for the font property
Since:
JavaFX 8.0
See Also:
  • getFont()
  • fontProperty()

getFont

public final Font getFont()
Gets the value of the font property.
Property description:
The default font to use for text in the TextInputControl. If the TextInputControl's text is rich text then this font may or may not be used depending on the font information embedded in the rich text, but in any case where a default font is required, this font will be used.
Returns:
the value of the font property
Since:
JavaFX 8.0
See Also:
  • setFont(Font)
  • fontProperty()

promptTextProperty

public final StringProperty promptTextProperty()
The prompt text to display in the TextInputControl. If set to null or an empty string, no prompt text is displayed.
Default value:
An empty String
Returns:
the promptText property
Since:
JavaFX 2.2
See Also:
  • getPromptText()
  • setPromptText(String)

getPromptText

public final String getPromptText()
Gets the value of the promptText property.
Property description:
The prompt text to display in the TextInputControl. If set to null or an empty string, no prompt text is displayed.
Default value:
An empty String
Returns:
the value of the promptText property
Since:
JavaFX 2.2
See Also:
  • setPromptText(String)
  • promptTextProperty()

setPromptText

public final void setPromptText(String value)
Sets the value of the promptText property.
Property description:
The prompt text to display in the TextInputControl. If set to null or an empty string, no prompt text is displayed.
Default value:
An empty String
Parameters:
value - the value for the promptText property
Since:
JavaFX 2.2
See Also:
  • getPromptText()
  • promptTextProperty()

textFormatterProperty

public final ObjectProperty<TextFormatter<?>> textFormatterProperty()
The property contains currently attached TextFormatter. Since the value is part of the Formatter, changing the TextFormatter will update the text based on the new textFormatter.
Default value:
null
Returns:
the textFormatter property
Since:
JavaFX 8u40
See Also:
  • getTextFormatter()
  • setTextFormatter(TextFormatter)

getTextFormatter

public final TextFormatter<?> getTextFormatter()
Gets the value of the textFormatter property.
Property description:
The property contains currently attached TextFormatter. Since the value is part of the Formatter, changing the TextFormatter will update the text based on the new textFormatter.
Default value:
null
Returns:
the value of the textFormatter property
Since:
JavaFX 8u40
See Also:
  • setTextFormatter(TextFormatter)
  • textFormatterProperty()

setTextFormatter

public final void setTextFormatter(TextFormatter<?> value)
Sets the value of the textFormatter property.
Property description:
The property contains currently attached TextFormatter. Since the value is part of the Formatter, changing the TextFormatter will update the text based on the new textFormatter.
Default value:
null
Parameters:
value - the value for the textFormatter property
Since:
JavaFX 8u40
See Also:
  • getTextFormatter()
  • textFormatterProperty()

getContent

protected final TextInputControl.Content getContent()
Returns the text input's content model.
Returns:
the text input's content model

getText

public final String getText()
Gets the value of the text property.
Property description:
The textual content of this TextInputControl.
Returns:
the value of the text property
See Also:
  • setText(String)
  • textProperty()

setText

public final void setText(String value)
Sets the value of the text property.
Property description:
The textual content of this TextInputControl.
Parameters:
value - the value for the text property
See Also:
  • getText()
  • textProperty()

textProperty

public final StringProperty textProperty()
The textual content of this TextInputControl.
Returns:
the text property
See Also:
  • getText()
  • setText(String)

getLength

public final int getLength()
Gets the value of the length property.
Property description:
The number of characters in the text input.
Returns:
the value of the length property
See Also:
  • lengthProperty()

lengthProperty

public final ReadOnlyIntegerProperty lengthProperty()
The number of characters in the text input.
Returns:
the length property
See Also:
  • getLength()

isEditable

public final boolean isEditable()
Gets the value of the editable property.
Property description:
Indicates whether this TextInputControl can be edited by the user.
Returns:
the value of the editable property
See Also:
  • setEditable(boolean)
  • editableProperty()

setEditable

public final void setEditable(boolean value)
Sets the value of the editable property.
Property description:
Indicates whether this TextInputControl can be edited by the user.
Parameters:
value - the value for the editable property
See Also:
  • isEditable()
  • editableProperty()

editableProperty

public final BooleanProperty editableProperty()
Indicates whether this TextInputControl can be edited by the user.
Returns:
the editable property
See Also:
  • isEditable()
  • setEditable(boolean)

getSelection

public final IndexRange getSelection()
Gets the value of the selection property.
Property description:
The current selection.
Returns:
the value of the selection property
See Also:
  • selectionProperty()

selectionProperty

public final ReadOnlyObjectProperty<IndexRange> selectionProperty()
The current selection.
Returns:
the selection property
See Also:
  • getSelection()

getSelectedText

public final String getSelectedText()
Gets the value of the selectedText property.
Property description:
Defines the characters in the TextInputControl which are selected
Returns:
the value of the selectedText property
See Also:
  • selectedTextProperty()

selectedTextProperty

public final ReadOnlyStringProperty selectedTextProperty()
Defines the characters in the TextInputControl which are selected
Returns:
the selectedText property
See Also:
  • getSelectedText()

getAnchor

public final int getAnchor()
Gets the value of the anchor property.
Property description:
The anchor of the text selection. The anchor and caretPosition make up the selection range. Selection must always be specified in terms of begin <= end, but anchor may be less than, equal to, or greater than the caretPosition. Depending on how the user selects text, the anchor might represent the lower or upper bound of the selection.
Returns:
the value of the anchor property
See Also:
  • anchorProperty()

anchorProperty

public final ReadOnlyIntegerProperty anchorProperty()
The anchor of the text selection. The anchor and caretPosition make up the selection range. Selection must always be specified in terms of begin <= end, but anchor may be less than, equal to, or greater than the caretPosition. Depending on how the user selects text, the anchor might represent the lower or upper bound of the selection.
Returns:
the anchor property
See Also:
  • getAnchor()

getCaretPosition

public final int getCaretPosition()
Gets the value of the caretPosition property.
Property description:
The current position of the caret within the text. The anchor and caretPosition make up the selection range. Selection must always be specified in terms of begin <= end, but anchor may be less than, equal to, or greater than the caretPosition. Depending on how the user selects text, the caretPosition might represent the lower or upper bound of the selection.
Returns:
the value of the caretPosition property
See Also:
  • caretPositionProperty()

caretPositionProperty

public final ReadOnlyIntegerProperty caretPositionProperty()
The current position of the caret within the text. The anchor and caretPosition make up the selection range. Selection must always be specified in terms of begin <= end, but anchor may be less than, equal to, or greater than the caretPosition. Depending on how the user selects text, the caretPosition might represent the lower or upper bound of the selection.
Returns:
the caretPosition property
See Also:
  • getCaretPosition()

isUndoable

public final boolean isUndoable()
Gets the value of the undoable property.
Property description:
The property describes if it's currently possible to undo the latest change of the content that was done.
Default value:
false
Returns:
the value of the undoable property
Since:
JavaFX 8u40
See Also:
  • undoableProperty()

undoableProperty

public final ReadOnlyBooleanProperty undoableProperty()
The property describes if it's currently possible to undo the latest change of the content that was done.
Default value:
false
Returns:
the undoable property
Since:
JavaFX 8u40
See Also:
  • isUndoable()

isRedoable

public final boolean isRedoable()
Gets the value of the redoable property.
Property description:
The property describes if it's currently possible to redo the latest change of the content that was undone.
Default value:
false
Returns:
the value of the redoable property
Since:
JavaFX 8u40
See Also:
  • redoableProperty()

redoableProperty

public final ReadOnlyBooleanProperty redoableProperty()
The property describes if it's currently possible to redo the latest change of the content that was undone.
Default value:
false
Returns:
the redoable property
Since:
JavaFX 8u40
See Also:
  • isRedoable()

getText

public String getText(int start, int end)
Returns a subset of the text input's content.
Parameters:
start - must be a value between 0 and end - 1.
end - must be less than or equal to the length
Returns:
the subset of the text input's content

appendText

public void appendText(String text)
Appends a sequence of characters to the content.
Parameters:
text - a non null String

insertText

public void insertText(int index, String text)
Inserts a sequence of characters into the content.
Parameters:
index - The location to insert the text.
text - The text to insert.

deleteText

public void deleteText(IndexRange range)
Removes a range of characters from the content.
Parameters:
range - The range of text to delete. The range object must not be null.
See Also:
  • deleteText(int, int)

deleteText

public void deleteText(int start, int end)
Removes a range of characters from the content.
Parameters:
start - The starting index in the range, inclusive. This must be >= 0 and < the end.
end - The ending index in the range, exclusive. This is one-past the last character to delete (consistent with the String manipulation methods). This must be > the start, and <= the length of the text.

replaceText

public void replaceText(IndexRange range, String text)
Replaces a range of characters with the given text.
Parameters:
range - The range of text to replace. The range object must not be null.
text - The text that is to replace the range. This must not be null.
See Also:
  • replaceText(int, int, String)

replaceText

public void replaceText(int start, int end, String text)
Replaces a range of characters with the given text.
Parameters:
start - The starting index in the range, inclusive. This must be >= 0 and < the end.
end - The ending index in the range, exclusive. This is one-past the last character to delete (consistent with the String manipulation methods). This must be > the start, and <= the length of the text.
text - The text that is to replace the range. This must not be null.

cut

public void cut()
Transfers the currently selected range in the text to the clipboard, removing the current selection.

copy

public void copy()
Transfers the currently selected range in the text to the clipboard, leaving the current selection.

paste

public void paste()
Transfers the contents in the clipboard into this text, replacing the current selection. If there is no selection, the contents in the clipboard is inserted at the current caret position.

selectBackward

public void selectBackward()
Moves the selection backward one char in the text. This may have the effect of deselecting, depending on the location of the anchor relative to the caretPosition. This function effectively just moves the caretPosition.

selectForward

public void selectForward()
Moves the selection forward one char in the text. This may have the effect of deselecting, depending on the location of the anchor relative to the caretPosition. This function effectively just moves the caret forward.

previousWord

public void previousWord()
Moves the caret to the beginning of previous word. This function also has the effect of clearing the selection.

nextWord

public void nextWord()
Moves the caret to the beginning of next word. This function also has the effect of clearing the selection.

endOfNextWord

public void endOfNextWord()
Moves the caret to the end of the next word. This function also has the effect of clearing the selection.

selectPreviousWord

public void selectPreviousWord()
Moves the caret to the beginning of previous word. This does not cause the selection to be cleared. Rather, the anchor stays put and the caretPosition is moved to the beginning of previous word.

selectNextWord

public void selectNextWord()
Moves the caret to the beginning of next word. This does not cause the selection to be cleared. Rather, the anchor stays put and the caretPosition is moved to the beginning of next word.

selectEndOfNextWord

public void selectEndOfNextWord()
Moves the caret to the end of the next word. This does not cause the selection to be cleared.

selectAll

public void selectAll()
Selects all text in the text input.

home

public void home()
Moves the caret to before the first char of the text. This function also has the effect of clearing the selection.

end

public void end()
Moves the caret to after the last char of the text. This function also has the effect of clearing the selection.

selectHome

public void selectHome()
Moves the caret to before the first char of text. This does not cause the selection to be cleared. Rather, the anchor stays put and the caretPosition is moved to before the first char.

selectEnd

public void selectEnd()
Moves the caret to after the last char of text. This does not cause the selection to be cleared. Rather, the anchor stays put and the caretPosition is moved to after the last char.

deletePreviousChar

public boolean deletePreviousChar()
Deletes the character that precedes the current caret position from the text if there is no selection, or deletes the selection if there is one. This function returns true if the deletion succeeded, false otherwise.
Returns:
true if the deletion succeeded, false otherwise

deleteNextChar

public boolean deleteNextChar()
Deletes the character that follows the current caret position from the text if there is no selection, or deletes the selection if there is one. This function returns true if the deletion succeeded, false otherwise.
Returns:
true if the deletion succeeded, false otherwise

forward

public void forward()
Moves the caret position forward. If there is no selection, then the caret position is moved one character forward. If there is a selection, then the caret position is moved to the end of the selection and the selection cleared.

backward

public void backward()
Moves the caret position backward. If there is no selection, then the caret position is moved one character backward. If there is a selection, then the caret position is moved to the beginning of the selection and the selection cleared. Note: This function is intended to be used by experts, primarily by those implementing new Skins or Behaviors. It is not common for developers or designers to access this function directly.

positionCaret

public void positionCaret(int pos)
Positions the caret to the position indicated by pos. This function will also clear the selection.
Parameters:
pos - the position

selectPositionCaret

public void selectPositionCaret(int pos)
Positions the caret to the position indicated by pos and extends the selection, if there is one. If there is no selection, then a selection is formed where the anchor is at the current caret position and the caretPosition is moved to pos.
Parameters:
pos - the position

selectRange

public void selectRange(int anchor, int caretPosition)
Positions the anchor and caretPosition explicitly.
Parameters:
anchor - the anchor
caretPosition - the caretPosition

extendSelection

public void extendSelection(int pos)
This function will extend the selection to include the specified pos. This is different from selectPositionCaret in that it does not simply move the caret. Rather, it will reposition the caret and anchor as necessary to ensure that pos becomes the new caret and the far other end of the selection becomes the anchor.
Parameters:
pos - the position

clear

public void clear()
Clears the text.

deselect

public void deselect()
Clears the selection.

replaceSelection

public void replaceSelection(String replacement)
Replaces the selection with the given replacement String. If there is no selection, then the replacement text is simply inserted at the current caret position. If there was a selection, then the selection is cleared and the given replacement text inserted.
Parameters:
replacement - the replacement string

undo

public final void undo()
If possible, undoes the last modification. If isUndoable() returns false, then calling this method has no effect.
Since:
JavaFX 8u40

redo

public final void redo()
If possible, redoes the last undone modification. If isRedoable() returns false, then calling this method has no effect.
Since:
JavaFX 8u40

commitValue

public final void commitValue()
Commit the current text and convert it to a value.
Since:
JavaFX 8u40

cancelEdit

public final void cancelEdit()
If the field is currently being edited, this call will set text to the last commited value.
Since:
JavaFX 8u40

getClassCssMetaData

public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
Returns:
the CssMetaData
Since:
JavaFX 8.0

getControlCssMetaData

public List<CssMetaData<? extends Styleable,?>> getControlCssMetaData()
Gets the unmodifiable list of the control's CSS-styleable properties.
Overrides:
getControlCssMetaData in class Control
Returns:
the unmodifiable list of the control's CSS-styleable properties
Since:
JavaFX 8.0

© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API