Top Description Fields Constructors Methods
org.fxmisc.richtext

public abstract Class StyledTextField<PS, S>

extends StyledTextArea<PS, S>
Class Inheritance
Known Direct Subclasses
org.fxmisc.richtext.InlineCssTextField, org.fxmisc.richtext.StyleClassedTextField
Type Parameters
<PS>
type of paragraph style
<S>
type of style that can be applied to text.
Imports
java.util.ArrayList, .Collections, .List, java.util.function.BiConsumer, java.util.regex.Pattern, org.fxmisc.richtext.model.EditableStyledDocument, javafx.application.Application, .Platform, javafx.beans.NamedArg, javafx.beans.binding.Bindings, javafx.beans.property.ObjectProperty, .ObjectPropertyBase, javafx.css.CssMetaData, .StyleConverter, .Styleable, .StyleableObjectProperty, javafx.event.ActionEvent, .EventHandler, javafx.geometry.Pos, javafx.scene.AccessibleRole, .Group, .Node, .Parent, .Scene, javafx.scene.control.TextField, javafx.scene.input.KeyCode, .KeyEvent, .MouseEvent, javafx.scene.layout.Pane, javafx.scene.paint.Color, .Paint, javafx.scene.shape.Rectangle, javafx.scene.text.Text, .TextAlignment, .TextFlow

A text field whose segment generic has been specified to be a String. How the text will be styled is not yet specified in this class, but use StyleClassedTextField for a style class approach to styling the text and InlineCssTextField for an inline css approach to styling the text.

Use CSS Style Class ".styled-text-field" for styling the control.

Author
Jurgen

Field Summary

Modifier and TypeField and Description
private static final List<CssMetaData<? extends Styleable, ?>>
private static double
private ObjectProperty<EventHandler<ActionEvent>>
onAction

The action handler associated with this text field, or null if no action handler is assigned.

private static final CssMetaData<StyledTextField<PS, S>, Paint>
private StyleableObjectProperty<Paint>
private boolean
private static final String
private static final CssMetaData<StyledTextField<PS, S>, TextAlignment>
private StyleableObjectProperty<TextAlignment>
private static final Pattern

Constructor Summary

AccessConstructor and Description
public
StyledTextField(PS initialParagraphStyle, BiConsumer<TextFlow, PS> applyParagraphStyle, S initialTextStyle, BiConsumer<? super TextExt, S> applyStyle, EditableStyledDocument<PS, String, S> document)

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<TextAlignment>
alignmentProperty()

Specifies how the text should be aligned when there is empty space within the TextField.

private double
protected abstract void
protected void
configurePlaceholder(Node placeholder)

Overrides org.fxmisc.richtext.GenericStyledArea.configurePlaceholder.

Override this to customize the placeholder's layout.

public final TextAlignment
public static List<CssMetaData<? extends Styleable, ?>>
getClassCssMetaData()

Hides org.fxmisc.richtext.GenericStyledArea.getClassCssMetaData.

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

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

Overrides org.fxmisc.richtext.GenericStyledArea.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

public final EventHandler<ActionEvent>
public final Text
public boolean
isWrapText()

Overrides org.fxmisc.richtext.GenericStyledArea.isWrapText.

Overrides default org.fxmisc.richtext.ViewActions.isWrapText.

This always returns false for styled text fields.

public final ObjectProperty<EventHandler<ActionEvent>>
private final ObjectProperty<Paint>
public final ObjectProperty<? super Text>
public void
replaceText(int start, int end, String text)

Overrides org.fxmisc.richtext.GenericStyledArea.replaceText.

Implements org.fxmisc.richtext.TextEditingArea.replaceText.

Replaces a range of characters with the given text.

public final void
public final void
public void
setPlaceholder(Node value, Pos where)

Overrides org.fxmisc.richtext.GenericStyledArea.setPlaceholder.

setPlaceholder is not supported by StyledTextField, use setPromptText instead

public final void
setPromptText(Text value)

The prompt text to display or null if no prompt text is to be displayed.

public void
public void
setWrapText(boolean value)

Overrides org.fxmisc.richtext.GenericStyledArea.setWrapText.

Overrides default org.fxmisc.richtext.ViewActions.setWrapText.

Deprecated

This is a no op for text fields and therefore marked as deprecated.

private Node
traverse(Parent p, Node from, int dir)

Inherited from org.fxmisc.richtext.StyledTextArea:
createStyledTextNodecreateStyledTextNode

Field Detail

CSS_META_DATA_LISTback to summary
private static final List<CssMetaData<? extends Styleable, ?>> CSS_META_DATA_LIST

Hides org.fxmisc.richtext.GenericStyledArea.CSS_META_DATA_LIST.

HEIGHTback to summary
private static double HEIGHT
onActionback to summary
private ObjectProperty<EventHandler<ActionEvent>> onAction

The action handler associated with this text field, or null if no action handler is assigned. The action handler is normally called when the user types the ENTER key.

PROMPT_TEXT_FILLback to summary
private static final CssMetaData<StyledTextField<PS, S>, Paint> PROMPT_TEXT_FILL
promptFillPropback to summary
private StyleableObjectProperty<Paint> promptFillProp
selectAllback to summary
private boolean selectAll
STYLE_SHEETback to summary
private static final String STYLE_SHEET
TEXT_ALIGNMENTback to summary
private static final CssMetaData<StyledTextField<PS, S>, TextAlignment> TEXT_ALIGNMENT
textAlignmentback to summary
private StyleableObjectProperty<TextAlignment> textAlignment
VERTICAL_WHITESPACEback to summary
private static final Pattern VERTICAL_WHITESPACE

Constructor Detail

StyledTextFieldback to summary
public StyledTextField(PS initialParagraphStyle, BiConsumer<TextFlow, PS> applyParagraphStyle, S initialTextStyle, BiConsumer<? super TextExt, S> applyStyle, EditableStyledDocument<PS, String, S> document)

Method Detail

alignmentPropertyback to summary
public final ObjectProperty<TextAlignment> alignmentProperty()

Specifies how the text should be aligned when there is empty space within the TextField. To configure via CSS use -fx-alignment: and values from javafx.scene.text.TextAlignment.

calcHorizontalPosback to summary
private double calcHorizontalPos()
changeAlignmentback to summary
protected abstract void changeAlignment(TextAlignment txtAlign)
configurePlaceholderback to summary
protected void configurePlaceholder(Node placeholder)

Overrides org.fxmisc.richtext.GenericStyledArea.configurePlaceholder.

Doc from org.fxmisc.richtext.GenericStyledArea.configurePlaceholder.

Override this to customize the placeholder's layout.
The default position is centered over the area.

Annotations
@Override
getAlignmentback to summary
public final TextAlignment getAlignment()
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides org.fxmisc.richtext.GenericStyledArea.getClassCssMetaData.

Doc from javafx.scene.layout.Region.getClassCssMetaData.

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

getCssMetaDataback to summary
public List<CssMetaData<? extends Styleable, ?>> getCssMetaData()

Overrides org.fxmisc.richtext.GenericStyledArea.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

Doc from javafx.scene.layout.Region.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

Annotations
@Override
getOnActionback to summary
public final EventHandler<ActionEvent> getOnAction()
getPromptTextback to summary
public final Text getPromptText()
isWrapTextback to summary
public boolean isWrapText()

Overrides org.fxmisc.richtext.GenericStyledArea.isWrapText.

Overrides default org.fxmisc.richtext.ViewActions.isWrapText.

This always returns false for styled text fields.

Annotations
@Override
onActionPropertyback to summary
public final ObjectProperty<EventHandler<ActionEvent>> onActionProperty()
promptTextFillPropertyback to summary
private final ObjectProperty<Paint> promptTextFillProperty()
promptTextPropertyback to summary
public final ObjectProperty<? super Text> promptTextProperty()
replaceTextback to summary
public void replaceText(int start, int end, String text)

Overrides org.fxmisc.richtext.GenericStyledArea.replaceText.

Implements org.fxmisc.richtext.TextEditingArea.replaceText.

Doc from org.fxmisc.richtext.TextEditingArea.replaceText.

Replaces a range of characters with the given text. It must hold 0 <= start <= end <= getLength().

Annotations
@Override
setAlignmentback to summary
public final void setAlignment(TextAlignment value)
setOnActionback to summary
public final void setOnAction(EventHandler<ActionEvent> value)
setPlaceholderback to summary
public void setPlaceholder(Node value, Pos where)

Overrides org.fxmisc.richtext.GenericStyledArea.setPlaceholder.

setPlaceholder is not supported by StyledTextField, use setPromptText instead

Annotations
@Override
setPromptTextback to summary
public final void setPromptText(Text value)

The prompt text to display or null if no prompt text is to be displayed.

The Text will be aligned according to the text fields alignment setting and have a default text fill of GRAY unless you have changed it by any means, e.g. with CSS "-fx-prompt-text-fill"

setTextback to summary
public void setText(String text)
setWrapTextback to summary
public void setWrapText(boolean value)

Overrides org.fxmisc.richtext.GenericStyledArea.setWrapText.

Overrides default org.fxmisc.richtext.ViewActions.setWrapText.

Deprecated

This is a no op for text fields and therefore marked as deprecated.

Annotations
@Override
@Deprecated
traverseback to summary
private Node traverse(Parent p, Node from, int dir)