Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Text

[62:7] extends: Shape

Wraps JavaFX Text, a node that displays a string using a specified font, supporting rich text styling via CSS. Text extends Shape, so it inherits all Shape styling in addition to its own text-specific properties. It is distinct from Label, which is a UI control.

CSS Properties -- Text

Property Values Default Description
-fx-bounds-type visual | logical | logical-vertical-center logical Determines which bounds type is used for layout.
-fx-font <font> system default Font used to render the text content.
-fx-font-smoothing-type gray | lcd gray Anti-aliasing strategy for the text glyphs.
-fx-line-spacing <size> 0 Additional space between lines in multi-line text.
-fx-fill <paint> black Color used to fill the text glyphs.
-fx-strikethrough true | false false When true, a line is drawn through the middle of the text.
-fx-tab-size <integer> 8 Number of spaces a tab character expands to.
-fx-text-alignment left | center | right | justify left Horizontal alignment of multi-line text.
-fx-text-origin baseline | top | bottom baseline Vertical origin of the text relative to the node's bounding box.
-fx-underline true | false false When true, a line is drawn beneath each line of text.

CSS Properties -- Shape

Property Values Default Description
-fx-smooth true | false true When true, anti-aliasing is applied to the shape edges.
-fx-stroke <paint> null Paint for the shape outline stroke. No stroke is drawn when null.
-fx-stroke-type inside | outside | centered centered Position of the stroke relative to the shape boundary.
-fx-stroke-dash-array <size> [<size>]* (none) Pattern of dashes and gaps for a dashed stroke.
-fx-stroke-dash-offset <number> 0 Offset into the dash pattern at which to begin rendering.
-fx-stroke-line-cap square | butt | round square Style of the end caps on open path strokes.
-fx-stroke-line-join miter | bevel | round miter Style used at corners where two stroke segments meet.
-fx-stroke-miter-limit <number> 10 Limit on the ratio of miter length to stroke width; beyond this the join becomes a bevel.
-fx-stroke-width <size> 1 Width of the shape stroke in pixels.

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.
-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.
-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.
-fx-managed true | false true When false, the parent layout does not manage this node's position or size.

Methods

  • Text (double X = 0.0, double Y = 0.0, string TextStr = "")

    Creates a new Text node at the given position displaying the given string.

    • @p X is a double with the X coordinate of the text origin.
    • @p Y is a double with the Y coordinate of the text baseline.
    • @p TextStr is a string with the text content to display.
  • setText (string TextStr)

    Sets the text string displayed by this node.

    • @p TextStr is a string with the new text content.
    • @r this object
  • getText ()

    Returns the current text string displayed by this node.

    • @r A string with the current text content.
  • setFont (object FontObj)

    Sets the font used to render the text.

    • @p FontObj is a Font object specifying the typeface, style, and size.
    • @r this object
  • setFill (object PaintObj)

    Sets the fill paint for the text glyphs.

    • @p PaintObj is a paint object used to fill the text characters.
    • @r this object
  • setStroke (object PaintObj)

    Sets the stroke paint for the text glyph outlines.

    • @p PaintObj is a paint object used to draw the text character outlines.
    • @r this object
  • setStrokeWidth (double W)

    Sets the width of the text glyph outline stroke.

    • @p W is a double with the stroke width in pixels.
    • @r this object
  • setWrappingWidth (double W)

    Sets the wrapping width of the text, causing it to wrap to the next line when exceeded.

    • @p W is a double with the maximum line width in pixels; 0 disables wrapping.
    • @r this object
  • textProperty ()

    Returns the text StringProperty for binding.

    • @r An AJO around the StringProperty.
  • setX (double Value)

    Sets the X coordinate of the text origin.

    • @p Value is a double with the X position.
    • @r this object for chaining
  • getX ()

    Returns the X coordinate of the text origin.

    • @r A double with the X position.
  • xProperty ()

    Returns the x DoubleProperty for binding.

    • @r An AJO around the DoubleProperty.
  • setY (double Value)

    Sets the Y coordinate of the text baseline.

    • @p Value is a double with the Y position.
    • @r this object for chaining
  • getY ()

    Returns the Y coordinate of the text baseline.

    • @r A double with the Y position.
  • yProperty ()

    Returns the y DoubleProperty for binding.

    • @r An AJO around the DoubleProperty.
  • getFont ()

    Returns the current font used to render the text.

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

    Returns the font ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • setTextOrigin (string Origin)

    Sets the vertical origin of the text relative to the node bounds.

    • @p Origin is a string VPos value: TOP, CENTER, BASELINE, BOTTOM.
    • @r this object for chaining
  • getTextOrigin ()

    Returns the current text origin.

    • @r An AJO around the javafx.geometry.VPos value.
  • textOriginProperty ()

    Returns the textOrigin ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • setBoundsType (string BType)

    Sets the bounds type used during layout.

    • @p BType is a string TextBoundsType value: LOGICAL, VISUAL, LOGICAL_VERTICAL_CENTER.
    • @r this object for chaining
  • getBoundsType ()

    Returns the current bounds type.

    • @r An AJO around the TextBoundsType value.
  • boundsTypeProperty ()

    Returns the boundsType ObjectProperty for binding.

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

    Returns the wrapping width in pixels; 0 disables wrapping.

    • @r A double with the wrapping width.
  • wrappingWidthProperty ()

    Returns the wrappingWidth DoubleProperty for binding.

    • @r An AJO around the DoubleProperty.
  • setUnderline (bool Value)

    Sets whether each line is drawn with an underline.

    • @p Value is a bool with true to underline.
    • @r this object for chaining
  • isUnderline ()

    Returns whether the text is underlined.

    • @r A bool with true if underline is on.
  • underlineProperty ()

    Returns the underline BooleanProperty for binding.

    • @r An AJO around the BooleanProperty.
  • setStrikethrough (bool Value)

    Sets whether a line is drawn through the middle of the text.

    • @p Value is a bool with true to strike through.
    • @r this object for chaining
  • isStrikethrough ()

    Returns whether the text is struck through.

    • @r A bool with true if strikethrough is on.
  • strikethroughProperty ()

    Returns the strikethrough BooleanProperty for binding.

    • @r An AJO around the BooleanProperty.
  • setTextAlignment (string Align)

    Sets the horizontal alignment of multi-line text.

    • @p Align is a string TextAlignment value: LEFT, CENTER, RIGHT, JUSTIFY.
    • @r this object for chaining
  • getTextAlignment ()

    Returns the current text alignment.

    • @r An AJO around the TextAlignment value.
  • textAlignmentProperty ()

    Returns the textAlignment ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • setLineSpacing (double Value)

    Sets additional space between lines in multi-line text.

    • @p Value is a double with the line spacing in pixels.
    • @r this object for chaining
  • getLineSpacing ()

    Returns the current line spacing in pixels.

    • @r A double with the line spacing.
  • lineSpacingProperty ()

    Returns the lineSpacing DoubleProperty for binding.

    • @r An AJO around the DoubleProperty.
  • baselineOffsetProperty ()

    Returns the baselineOffset ReadOnlyDoubleProperty for binding.

    • @r An AJO around the ReadOnlyDoubleProperty.
  • setFontSmoothingType (string SType)

    Sets the font smoothing strategy.

    • @p SType is a string FontSmoothingType value: GRAY or LCD.
    • @r this object for chaining
  • getFontSmoothingType ()

    Returns the current font smoothing type.

    • @r An AJO around the FontSmoothingType value.
  • fontSmoothingTypeProperty ()

    Returns the fontSmoothingType ObjectProperty for binding.

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

    Returns the shape representing the current selection.

    • @r An AJO around the PathElement array, or null.
  • selectionShapeProperty ()

    Returns the selectionShape ReadOnlyObjectProperty for binding.

    • @r An AJO around the ReadOnlyObjectProperty.
  • setSelectionStart (int Value)

    Sets the selection start character index.

    • @p Value is an int with the start index.
    • @r this object for chaining
  • getSelectionStart ()

    Returns the selection start character index.

    • @r An int with the start index.
  • selectionStartProperty ()

    Returns the selectionStart IntegerProperty for binding.

    • @r An AJO around the IntegerProperty.
  • setSelectionEnd (int Value)

    Sets the selection end character index.

    • @p Value is an int with the end index.
    • @r this object for chaining
  • getSelectionEnd ()

    Returns the selection end character index.

    • @r An int with the end index.
  • selectionEndProperty ()

    Returns the selectionEnd IntegerProperty for binding.

    • @r An AJO around the IntegerProperty.
  • selectionFillProperty ()

    Returns the selectionFill ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • setSelectionFill (object PaintObj)

    Sets the paint used to render the selected text.

    • @p PaintObj is a paint wrapper object.
    • @r this object for chaining
  • getSelectionFill ()

    Returns the current selection fill paint.

    • @r An AJO around the Paint, or null.
  • getCaretShape ()

    Returns the shape representing the caret position.

    • @r An AJO around the PathElement array.
  • caretShapeProperty ()

    Returns the caretShape ReadOnlyObjectProperty for binding.

    • @r An AJO around the ReadOnlyObjectProperty.
  • setCaretPosition (int Value)

    Sets the caret position by character index.

    • @p Value is an int with the caret position.
    • @r this object for chaining
  • getCaretPosition ()

    Returns the current caret position by character index.

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

    Returns the caretPosition IntegerProperty for binding.

    • @r An AJO around the IntegerProperty.
  • setCaretBias (bool Value)

    Sets the caret bias. A bias of true places the caret on the leading edge of the character at the caret position; false places it on the trailing edge.

    • @p Value is a bool with the bias.
    • @r this object for chaining
  • isCaretBias ()

    Returns the current caret bias.

    • @r A bool with the bias.
  • caretBiasProperty ()

    Returns the caretBias BooleanProperty for binding.

    • @r An AJO around the BooleanProperty.
  • hitTest (object PointObj)

    Returns the HitInfo for the given local-coordinate point.

    • @p PointObj is a Point2D wrapper or AJO.
    • @r An AJO around the javafx.scene.text.HitInfo.
  • caretShape (int Index, bool Bias)

    Returns the shape of the caret at the given character index.

    • @p Index is an int with the character index.
    • @p Bias is a bool with the leading-edge bias.
    • @r An AJO around the PathElement array.
  • rangeShape (int Start, int End)

    Returns the shape outlining the character range from Start to End.

    • @p Start is an int with the start character index.
    • @p End is an int with the end character index.
    • @r An AJO around the PathElement array.
  • underlineShape (int Start, int End)

    Returns the underline shape for the character range Start to End.

    • @p Start is an int with the start character index.
    • @p End is an int with the end character index.
    • @r An AJO around the PathElement array.
  • tabSizeProperty ()

    Returns the tabSize IntegerProperty for binding.

    • @r An AJO around the IntegerProperty.
  • getTabSize ()

    Returns the current tab size in spaces.

    • @r An int with the tab size.
  • setTabSize (int Value)

    Sets the number of spaces a tab character expands to.

    • @p Value is an int with the tab size.
    • @r this object for chaining