APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.scene.control

public abstract Class TextInputControl

extends Control
Class Inheritance
Known Direct Subclasses
javafx.scene.control.TextArea, javafx.scene.control.TextField
Annotations
@DefaultProperty:text
Imports
com.sun.javafx.scene.control.FormatterAccessor, javafx.beans.DefaultProperty, .InvalidationListener, .Observable, javafx.beans.binding.IntegerBinding, javafx.beans.property.BooleanProperty, .ObjectProperty, .ObjectPropertyBase, .ReadOnlyBooleanProperty, .ReadOnlyBooleanWrapper, .ReadOnlyIntegerProperty, .ReadOnlyIntegerWrapper, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, .ReadOnlyStringProperty, .ReadOnlyStringWrapper, .SimpleBooleanProperty, .SimpleStringProperty, .StringProperty, javafx.beans.value.ChangeListener, .ObservableStringValue, .ObservableValue, .WritableValue, javafx.css.CssMetaData, .FontCssMetaData, .PseudoClass, .StyleOrigin, .Styleable, .StyleableObjectProperty, .StyleableProperty, javafx.scene.AccessibleAction, .AccessibleAttribute, javafx.scene.input.Clipboard, .ClipboardContent, javafx.scene.text.Font, java.text.BreakIterator, java.util.ArrayList, .Collections, .List, com.sun.javafx.util.Utils, com.sun.javafx.binding.ExpressionHelper, com.sun.javafx.scene.NodeHelper, javafx.util.StringConverter

Abstract base class for text input controls.
Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static interface
TextInputControl.Content

Interface representing a text input's content.

pack-priv abstract static class
TextInputControl.ContentBase

Package private base implementation of Content.

private static class
private class
private class
pack-priv static class
TextInputControl.UndoRedoChange

Used to form a linked-list of Undo / Redo changes.

Field Summary

Modifier and TypeField and Description
private FormatterAccessor
private ReadOnlyIntegerWrapper
anchor

The anchor of the text selection.

private boolean
private ReadOnlyIntegerWrapper
caretPosition

The current position of the caret within the text.

private BreakIterator
charIterator

The break iterator instances for navigation over words and complex characters.

private final TextInputControl.Content
private boolean
private BooleanProperty
editable

Indicates whether this TextInputControl can be edited by the user.

private ObjectProperty<Font>
private ReadOnlyIntegerWrapper
length

The number of characters in the text input.

private StringProperty
promptText

The prompt text to display in the TextInputControl.

private static final PseudoClass
private final ReadOnlyBooleanWrapper
redoable

The property describes if it's currently possible to redo the latest change of the content that was undone.

private ReadOnlyStringWrapper
selectedText

Defines the characters in the TextInputControl which are selected

private ReadOnlyObjectWrapper<IndexRange>
selection

The current selection.

private TextInputControl.TextProperty
text

The textual content of this TextInputControl.

private final ObjectProperty<TextFormatter<?>>
textFormatter

The property contains currently attached TextFormatter.

private final ReadOnlyBooleanWrapper
undoable

The property describes if it's currently possible to undo the latest change of the content that was done.

private TextInputControl.UndoRedoChange
private TextInputControl.UndoRedoChange
private BreakIterator

Constructor Summary

AccessConstructor and Description
protected
TextInputControl(final TextInputControl.Content
a non-null implementation of Content.
content
)

Creates a new TextInputControl.

Method Summary

Modifier and TypeMethod and Description
public final ReadOnlyIntegerProperty
public void
appendText(String
a non null String
text
)

Appends a sequence of characters to the content.

public void
backward()

Moves the caret position backward.

public final void
cancelEdit()

If the field is currently being edited, this call will set text to the last committed value.

public final ReadOnlyIntegerProperty
public void
clear()

Clears the text.

public final void
commitValue()

Commit the current text and convert it to a value.

pack-priv static boolean
containsInvalidCharacters(String txt, boolean newlineIllegal, boolean tabIllegal)

public void
copy()

Transfers the currently selected range in the text to the clipboard, leaving the current selection.

public void
cut()

Transfers the currently selected range in the text to the clipboard, removing the current selection.

public boolean

Returns:

true if the deletion succeeded, false otherwise
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.

public boolean

Returns:

true if the deletion succeeded, false otherwise
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.

public void
deleteText(IndexRange
The range of text to delete. The range object must not be null.
range
)

Removes a range of characters from the content.

public void
deleteText(int
The starting index in the range, inclusive. This must be >= 0 and < the end.
start
,
int
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.
end
)

Removes a range of characters from the content.

public void
deselect()

Clears the selection.

private void
doSelectRange(int anchor, int caretPosition)

public final BooleanProperty
public void
end()

Moves the caret to after the last char of the text.

public void
endOfNextWord()

Moves the caret to the end of the next word.

private void
endOfNextWord(boolean select)

public void
executeAccessibleAction(AccessibleAction action, Object... parameters)

Overrides javafx.scene.control.Control.executeAccessibleAction.

This method is called by the assistive technology to request the action indicated by the argument should be executed.

public void
extendSelection(int
the position
pos
)

This function will extend the selection to include the specified pos.

private boolean
pack-priv String
pack-priv static String

Returns:

The string after having the unwanted characters stripped out.
filterInput
(String txt, boolean stripNewlines, boolean stripTabs)

A little utility method for stripping out unwanted characters.

public final ObjectProperty<Font>

Returns:

the font property
fontProperty
()

The default font to use for text in the TextInputControl.

public void
forward()

Moves the caret position forward.

public final int
public final int
public static List<CssMetaData<? extends Styleable, ?>>

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.control.Control.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

protected final TextInputControl.Content

Returns:

the text input's content model
getContent
()

Returns the text input's content model.

public List<CssMetaData<? extends Styleable, ?>>
getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

public final Font
private FormatterAccessor
public final int
public final String
public final String
public final IndexRange
public final String
public String

Returns:

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

Returns a subset of the text input's content.

public final TextFormatter<?>
public void
home()

Moves the caret to before the first char of the text.

public void
insertText(int
The location to insert the text.
index
,
String
The text to insert.
text
)

Inserts a sequence of characters into the content.

public final boolean
private static boolean
isInvalidCharacter(char c, boolean newlineIllegal, boolean tabIllegal)

private static boolean
isLetterOrDigit(String text, int ix)

public final boolean
public final boolean
public final ReadOnlyIntegerProperty
public void
nextWord()

Moves the caret to the beginning of next word.

private void
nextWord(boolean select)

public void
paste()

Transfers the contents in the clipboard into this text, replacing the current selection.

public void
positionCaret(int
the position
pos
)

Positions the caret to the position indicated by pos.

public void
previousWord()

Moves the caret to the beginning of previous word.

private void
previousWord(boolean select)

public final StringProperty
public Object
queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)

Overrides javafx.scene.control.Control.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

public final void
redo()

If possible, redoes the last undone modification.

public final ReadOnlyBooleanProperty
public void
replaceSelection(String
the replacement string
replacement
)

Replaces the selection with the given replacement String.

public void
replaceText(IndexRange
The range of text to replace. The range object must not be null.
range
,
String
The text that is to replace the range. This must not be null.
text
)

Replaces a range of characters with the given text.

public void
replaceText(final int
The starting index in the range, inclusive. This must be >= 0 and < the end.
start
,
final int
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.
end
,
final String
The text that is to replace the range. This must not be null.
text
)

Replaces a range of characters with the given text.

private int

Returns:

The amount of adjustment made to the end / anchor / caretPosition to accommodate for subsequent filtering (such as the filtering of new lines by the TextField)
replaceText
(int
The start index into the existing text which will be replaced by the new value
start
,
int
The end index into the existing text which will be replaced by the new value. As with String.replace this is a lastIndex+1 value
end
,
String
The new text value
value
,
int
The new selection anchor after the change is made
anchor
,
int
The new selection caretPosition after the change is made.
caretPosition
)

This is what is ultimately called by every code path that will update the content (except for undo / redo).

private void
public void
selectAll()

Selects all text in the text input.

public void
selectBackward()

Moves the selection backward one char in the text.

public final ReadOnlyStringProperty
public void
selectEnd()

Moves the caret to after the last char of text.

public void
selectEndOfNextWord()

Moves the caret to the end of the next word.

public void
selectForward()

Moves the selection forward one char in the text.

public void
selectHome()

Moves the caret to before the first char of text.

public final ReadOnlyObjectProperty<IndexRange>
public void
selectNextWord()

Moves the caret to the beginning of next word.

public void
selectPositionCaret(int
the position
pos
)

Positions the caret to the position indicated by pos and extends the selection, if there is one.

public void
selectPreviousWord()

Moves the caret to the beginning of previous word.

public void
selectRange(int
the anchor
anchor
,
int
the caretPosition
caretPosition
)

Positions the anchor and caretPosition explicitly.

public final void
setEditable(boolean value)

public final void
setFont(Font value)

public final void
public final void
setText(String value)

public final void
public final ObjectProperty<TextFormatter<?>>
public final StringProperty
pack-priv void
public final void
undo()

If possible, undoes the last modification.

public final ReadOnlyBooleanProperty
private void
updateContent(TextFormatter.Change change, boolean forceNewUndoRecord)

private void
private <T> void
updateText(TextFormatter<T> formatter)

private void
Inherited from javafx.scene.control.Control:
computeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthcontextMenuPropertycreateDefaultSkingetBaselineOffsetgetContextMenugetControlChildrengetCssMetaDatagetInitialFocusTraversablegetSkingetTooltipisResizablelayoutChildrenloadSkinClasssetContextMenusetSkinsetTooltipskinClassNamePropertyskinPropertytooltipProperty