- java.lang.Object
- 
- javafx.scene.Node
- 
- javafx.scene.Parent
- 
- javafx.scene.layout.Region
- 
- javafx.scene.layout.Pane
- 
- javafx.scene.text.TextFlow
 
 
 
 
 
- 
- All Implemented Interfaces:
- Styleable,- EventTarget
 
 public class TextFlow extends Pane TextFlow is special layout designed to lay out rich text. It can be used to layout severalTextnodes in a single text flow. The TextFlow uses the text and the font of eachTextnode inside of it plus it own width and text alignment to determine the location for each child. A singleTextnode can span over several lines due to wrapping and the visual location ofTextnode can differ from the logical location due to bidi reordering.Any other Node, rather than Text, will be treated as embedded object in the text layout. It will be inserted in the content using its preferred width, height, and baseline offset. When a Textnode is inside of a TextFlow some its properties are ignored. For example, the x and y properties of theTextnode are ignored since the location of the node is determined by the parent. Likewise, the wrapping width in theTextnode is ignored since the width used for wrapping is the TextFlow's width. The value of thepickOnBoundsproperty of aTextis set tofalsewhen it is laid out by the TextFlow. This happens because the content of a singleTextnode can divided and placed in the different locations on the TextFlow (usually due to line breaking and bidi reordering).The wrapping width of the layout is determined by the region's current width. It can be specified by the application by setting the textflow's preferred width. If no wrapping is desired, the application can either set the preferred with to Double.MAX_VALUE or Region.USE_COMPUTED_SIZE. Paragraphs are separated by '\n'present in any Text child.Example of a TextFlow: Text text1 = new Text("Big italic red text"); text1.setFill(Color.RED); text1.setFont(Font.font("Helvetica", FontPosture.ITALIC, 40)); Text text2 = new Text(" little bold blue text"); text2.setFill(Color.BLUE); text2.setFont(Font.font("Helvetica", FontWeight.BOLD, 10)); TextFlow textFlow = new TextFlow(text1, text2);TextFlow lays out each managed child regardless of the child's visible property value; unmanaged children are ignored for all layout calculations. TextFlow may be styled with backgrounds and borders using CSS. See Regionsuperclass for details.Resizable RangeA textflow's parent will resize the textflow within the textflow's range during layout. By default the textflow computes this range based on its content as outlined in the tables below. TextFlow Resize Table width height minimum left/right insets top/bottom insets plus the height of the text content preferred left/right insets plus the width of the text content top/bottom insets plus the height of the text content maximum Double.MAX_VALUE Double.MAX_VALUE A textflow's unbounded maximum width and height are an indication to the parent that it may be resized beyond its preferred size to fill whatever space is assigned to it. TextFlow provides properties for setting the size range directly. These properties default to the sentinel value Region.USE_COMPUTED_SIZE, however the application may set them to other values as needed: 
 Applications may restore the computed values by setting these properties back to Region.USE_COMPUTED_SIZE.textflow.setMaxWidth(500);TextFlow does not clip its content by default, so it is possible that childrens' bounds may extend outside its own bounds if a child's pref size is larger than the space textflow has to allocate for it. - Since:
- JavaFX 8.0
 
- 
- 
Property SummaryProperties Type Property Description DoublePropertylineSpacingDefines the vertical space in pixel between lines.ObjectProperty<TextAlignment>textAlignmentDefines horizontal text alignment.- 
Properties inherited from class javafx.scene.layout.Regionbackground, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
 - 
Properties inherited from class javafx.scene.ParentneedsLayout
 - 
Properties inherited from class javafx.scene.NodeaccessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, 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
 
- 
 - 
Field Summary- 
Fields inherited from class javafx.scene.layout.RegionUSE_COMPUTED_SIZE, USE_PREF_SIZE
 - 
Fields inherited from class javafx.scene.NodeBASELINE_OFFSET_SAME_AS_HEIGHT
 
- 
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PathElement[]caretShape(int charIndex, boolean leading)Returns shape of caret in local coordinates.protected doublecomputeMinHeight(double width)Computes the minimum height of this region.protected doublecomputePrefHeight(double width)Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy.protected doublecomputePrefWidth(double height)Computes the preferred width of this region for the given height.doublegetBaselineOffset()Calculates the baseline offset based on the first managed child.static List<CssMetaData<? extends Styleable,?>>getClassCssMetaData()OrientationgetContentBias()Returns the orientation of a node's resizing bias for layout purposes.List<CssMetaData<? extends Styleable,?>>getCssMetaData()This method should delegate toNode.getClassCssMetaData()so that a Node's CssMetaData can be accessed without the need for reflection.doublegetLineSpacing()Gets the value of the property lineSpacing.TextAlignmentgetTextAlignment()Gets the value of the property textAlignment.HitInfohitTest(Point2D point)Maps local point to index in the content.protected voidlayoutChildren()Invoked during the layout pass to layout the children in thisParent.DoublePropertylineSpacingProperty()Defines the vertical space in pixel between lines.ObjectqueryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)This method is called by the assistive technology to request the value for an attribute.PathElement[]rangeShape(int start, int end)Returns shape for the range of the text in local coordinates.voidrequestLayout()Requests a layout pass to be performed before the next scene is rendered.voidsetLineSpacing(double spacing)Sets the value of the property lineSpacing.voidsetTextAlignment(TextAlignment value)Sets the value of the property textAlignment.protected voidsetWidth(double value)Sets the value of the property width.ObjectProperty<TextAlignment>textAlignmentProperty()Defines horizontal text alignment.booleanusesMirroring()Determines whether a node should be mirrored when node orientation is right-to-left.- 
Methods inherited from class javafx.scene.layout.PanegetChildren
 - 
Methods inherited from class javafx.scene.layout.RegionbackgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinWidth, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, 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, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty
 - 
Methods inherited from class javafx.scene.ParentgetChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestParentLayout, setNeedsLayout, updateBounds
 - 
Methods inherited from class javafx.scene.NodeaccessibleHelpProperty, 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, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, 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, 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, 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, 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, viewOrderProperty, visibleProperty
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface javafx.css.StyleablegetStyleableNode
 
- 
 
- 
- 
- 
Property Detail- 
textAlignmentpublic final ObjectProperty<TextAlignment> textAlignmentProperty Defines horizontal text alignment.- Default value:
- TextAlignment.LEFT
- See Also:
- getTextAlignment(),- setTextAlignment(TextAlignment)
 
 - 
lineSpacingpublic final DoubleProperty lineSpacingProperty Defines the vertical space in pixel between lines.- Default value:
- 0
- Since:
- JavaFX 8.0
- See Also:
- getLineSpacing(),- setLineSpacing(double)
 
 
- 
 - 
Constructor Detail- 
TextFlowpublic TextFlow() Creates an empty TextFlow layout.
 - 
TextFlowpublic TextFlow(Node... children) Creates a TextFlow layout with the given children.- Parameters:
- children- children.
 
 
- 
 - 
Method Detail- 
hitTestpublic final HitInfo hitTest(Point2D point) Maps local point to index in the content.- Parameters:
- point- the specified point to be tested
- Returns:
- a HitInforepresenting the character index found
- Since:
- 9
 
 - 
caretShapepublic PathElement[] caretShape(int charIndex, boolean leading) Returns shape of caret in local coordinates.- Parameters:
- charIndex- the character index for the caret
- leading- whether the caret is biased on the leading edge of the character
- Returns:
- an array of PathElementwhich can be used to create aShape
- Since:
- 9
 
 - 
rangeShapepublic final PathElement[] rangeShape(int start, int end) Returns shape for the range of the text in local coordinates.- Parameters:
- start- the beginning character index for the range
- end- the end character index (non-inclusive) for the range
- Returns:
- an array of PathElementwhich can be used to create aShape
- Since:
- 9
 
 - 
usesMirroringpublic boolean usesMirroring() Description copied from class:NodeDetermines whether a node should be mirrored when node orientation is right-to-left.When a node is mirrored, the origin is automatically moved to the top right corner causing the node to layout children and draw from right to left using a mirroring transformation. Some nodes may wish to draw from right to left without using a transformation. These nodes will will answer falseand implement right-to-left orientation without using the automatic transformation.- Overrides:
- usesMirroringin class- Node
- Returns:
- true if this Nodeshould be mirrored
 
 - 
setWidthprotected void setWidth(double value) Description copied from class:RegionSets the value of the property width.
 - 
computePrefWidthprotected double computePrefWidth(double height) Description copied from class:RegionComputes the preferred width of this region for the given height. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.- Overrides:
- computePrefWidthin class- Region
- Parameters:
- height- the height that should be used if preferred width depends on it
- Returns:
- the computed preferred width for this region
 
 - 
computePrefHeightprotected double computePrefHeight(double width) Description copied from class:RegionComputes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.- Overrides:
- computePrefHeightin class- Region
- Parameters:
- width- the width that should be used if preferred height depends on it
- Returns:
- the computed preferred height for this region
 
 - 
computeMinHeightprotected double computeMinHeight(double width) Description copied from class:RegionComputes the minimum height of this region. Returns the sum of the top and bottom insets by default. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.- Overrides:
- computeMinHeightin class- Region
- Parameters:
- width- the width that should be used if min height depends on it
- Returns:
- the computed minimum height for this region
 
 - 
requestLayoutpublic void requestLayout() Description copied from class:ParentRequests a layout pass to be performed before the next scene is rendered. This is batched up asynchronously to happen once per "pulse", or frame of animation.If this parent is either a layout root or unmanaged, then it will be added directly to the scene's dirty layout list, otherwise requestParentLayout will be invoked. - Overrides:
- requestLayoutin class- Parent
 
 - 
getContentBiaspublic Orientation getContentBias() Description copied from class:NodeReturns the orientation of a node's resizing bias for layout purposes. If the node type has no bias, returns null. If the node is resizable and it's height depends on its width, returns HORIZONTAL, else if its width depends on its height, returns VERTICAL.Resizable subclasses should override this method to return an appropriate value. - Overrides:
- getContentBiasin class- Node
- Returns:
- orientation of width/height dependency or null if there is none
- See Also:
- Node.isResizable(),- Node.minWidth(double),- Node.minHeight(double),- Node.prefWidth(double),- Node.prefHeight(double),- Node.maxWidth(double),- Node.maxHeight(double)
 
 - 
layoutChildrenprotected void layoutChildren() Description copied from class:ParentInvoked during the layout pass to layout the children in thisParent. By default it will only set the size of managed, resizable content to their preferred sizes and does not do any node positioning.Subclasses should override this function to layout content as needed. - Overrides:
- layoutChildrenin class- Parent
 
 - 
setTextAlignmentpublic final void setTextAlignment(TextAlignment value) Sets the value of the property textAlignment.- Property description:
- Defines horizontal text alignment.
- Default value:
- TextAlignment.LEFT
 
 - 
getTextAlignmentpublic final TextAlignment getTextAlignment() Gets the value of the property textAlignment.- Property description:
- Defines horizontal text alignment.
- Default value:
- TextAlignment.LEFT
 
 - 
textAlignmentPropertypublic final ObjectProperty<TextAlignment> textAlignmentProperty() Defines horizontal text alignment.- Default value:
- TextAlignment.LEFT
- See Also:
- getTextAlignment(),- setTextAlignment(TextAlignment)
 
 - 
setLineSpacingpublic final void setLineSpacing(double spacing) Sets the value of the property lineSpacing.- Property description:
- Defines the vertical space in pixel between lines.
- Default value:
- 0
- Since:
- JavaFX 8.0
 
 - 
getLineSpacingpublic final double getLineSpacing() Gets the value of the property lineSpacing.- Property description:
- Defines the vertical space in pixel between lines.
- Default value:
- 0
- Since:
- JavaFX 8.0
 
 - 
lineSpacingPropertypublic final DoubleProperty lineSpacingProperty() Defines the vertical space in pixel between lines.- Default value:
- 0
- Since:
- JavaFX 8.0
- See Also:
- getLineSpacing(),- setLineSpacing(double)
 
 - 
getBaselineOffsetpublic final double getBaselineOffset() Description copied from class:ParentCalculates the baseline offset based on the first managed child. If there is no such child, returnsNode.getBaselineOffset().- Overrides:
- getBaselineOffsetin class- Parent
- Returns:
- baseline offset
 
 - 
getClassCssMetaDatapublic static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData() - Returns:
- The CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
 
 - 
getCssMetaDatapublic List<CssMetaData<? extends Styleable,?>> getCssMetaData() Description copied from class:RegionThis method should delegate toNode.getClassCssMetaData()so that a Node's CssMetaData can be accessed without the need for reflection.- Specified by:
- getCssMetaDatain interface- Styleable
- Overrides:
- getCssMetaDatain class- Region
- Returns:
- The CssMetaData associated with this node, which may include the CssMetaData of its superclasses.
 
 - 
queryAccessibleAttributepublic Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) This method is called by the assistive technology to request the value for an attribute.This method is commonly overridden by subclasses to implement attributes that are required for a specific role. 
 If a particular attribute is not handled, the superclass implementation must be called.- Overrides:
- queryAccessibleAttributein class- Parent
- Parameters:
- attribute- the requested attribute
- parameters- optional list of parameters
- Returns:
- the value for the requested attribute
- See Also:
- AccessibleAttribute
 
 
- 
 
-