S - type of style that can be applied to text.public class StyledTextArea<PS,S> extends Region implements TextEditingArea<PS,S>, EditActions<PS,S>, ClipboardActions<PS,S>, NavigationActions<PS,S>, UndoActions, TwoDimensional, org.fxmisc.flowless.Virtualized
Subclassing is allowed to define the type of style, e.g. inline style or style classes.
Note: Scroll bars no longer appear when the content spans outside
of the viewport. To add scroll bars, the area needs to be wrapped in
a VirtualizedScrollPane. For example,
// shows area without scroll bars
InlineCssTextArea area = new InlineCssTextArea();
// add scroll bars that will display as needed
VirtualizedScrollPane<InlineCssTextArea> vsPane = new VirtualizedScrollPane(area);
Parent parent = //;
parent.getChildren().add(vsPane)
StyledTextArea uses KEY_TYPED handler to handle ordinary
character input and KEY_PRESSED handler to handle control key
combinations (including Enter and Tab). To add or override some keyboard
shortcuts, while keeping the rest in place, you would combine the default
event handler with a new one that adds or overrides some of the default
key combinations. This is how to bind Ctrl+S to the save()
operation:
import static javafx.scene.input.KeyCode.*;
import static javafx.scene.input.KeyCombination.*;
import static org.fxmisc.wellbehaved.event.EventPattern.*;
import static org.fxmisc.wellbehaved.event.InputMap.*;
import org.fxmisc.wellbehaved.event.Nodes;
Nodes.addInputMap(area, consume(keyPressed(S, CONTROL_DOWN), event -> save()));
| Type | Property and Description |
|---|---|
ObservableValue<Integer> |
anchor |
ObservableBooleanValue |
beingUpdated |
ObservableValue<Integer> |
caretColumn |
ObservableValue<Integer> |
caretPosition |
ObservableValue<Integer> |
currentParagraph |
BooleanProperty |
editable
Indicates whether this text area can be edited by the user.
|
org.reactfx.value.Var<Double> |
estimatedScrollX
The estimated scrollX value.
|
org.reactfx.value.Var<Double> |
estimatedScrollY
The estimated scrollY value.
|
ObservableValue<Integer> |
length |
ObjectProperty<Duration> |
mouseOverTextDelay
Defines how long the mouse has to stay still over the text before a
MouseOverTextEvent of type MOUSE_OVER_TEXT_BEGIN is
fired on this text area. |
ObjectProperty<IntFunction<? extends Node>> |
paragraphGraphicFactory |
ObjectProperty<PopupAlignment> |
popupAlignment
Defines where the popup window given in
popupWindowProperty()
is anchored, i.e. |
ObjectProperty<UnaryOperator<Point2D>> |
popupAnchorAdjustment
Specifies how to adjust the popup window's anchor point.
|
ObjectProperty<Point2D> |
popupAnchorOffset
Specifies further offset (in pixels) of the popup window from the
position specified by
popupAlignmentProperty(). |
ObjectProperty<PopupWindow> |
popupAtCaret
Deprecated.
|
ObjectProperty<PopupWindow> |
popupWindow
Popup window that will be positioned by this text area relative to the
caret or selection.
|
ObservableValue<String> |
selectedText |
ObservableValue<IndexRange> |
selection |
org.reactfx.value.Var<StyledTextArea.CaretVisibility> |
showCaret
Indicates when this text area should display a caret.
|
ObservableValue<String> |
text |
org.reactfx.value.Val<Double> |
totalHeightEstimate
The estimated height of the entire document.
|
org.reactfx.value.Val<Double> |
totalWidthEstimate
The estimated width of the entire document.
|
BooleanProperty |
useInitialStyleForInsertion
Indicates whether the initial style should also be used for plain text
inserted into this text area.
|
BooleanProperty |
wrapText
When a run of text exceeds the width of the text region,
then this property indicates whether the text should wrap
onto another line.
|
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, widthimpl_traversalEngine, needsLayoutaccessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, impl_showMnemonics, impl_treeVisible, 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, visibleredoAvailable, undoAvailable| Modifier and Type | Class and Description |
|---|---|
static class |
StyledTextArea.CaretVisibility |
NavigationActions.SelectionPolicyTwoDimensional.Bias, TwoDimensional.Position| Modifier and Type | Field and Description |
|---|---|
static IndexRange |
EMPTY_RANGE
Index range [0, 0).
|
USE_COMPUTED_SIZE, USE_PREF_SIZEBASELINE_OFFSET_SAME_AS_HEIGHT| Constructor and Description |
|---|
StyledTextArea(PS initialParagraphStyle,
BiConsumer<TextFlow,PS> applyParagraphStyle,
S initialTextStyle,
BiConsumer<? super TextExt,S> applyStyle)
Creates a text area with empty text content.
|
StyledTextArea(PS initialParagraphStyle,
BiConsumer<TextFlow,PS> applyParagraphStyle,
S initialTextStyle,
BiConsumer<? super TextExt,S> applyStyle,
boolean preserveStyle) |
StyledTextArea(PS initialParagraphStyle,
BiConsumer<TextFlow,PS> applyParagraphStyle,
S initialTextStyle,
BiConsumer<? super TextExt,S> applyStyle,
EditableStyledDocument<PS,S> document)
The same as
StyledTextArea(Object, BiConsumer, Object, BiConsumer) except that
this constructor can be used to create another StyledTextArea object that
shares the same EditableStyledDocument. |
StyledTextArea(PS initialParagraphStyle,
BiConsumer<TextFlow,PS> applyParagraphStyle,
S initialTextStyle,
BiConsumer<? super TextExt,S> applyStyle,
EditableStyledDocument<PS,S> document,
boolean preserveStyle) |
| Modifier and Type | Method and Description |
|---|---|
ObservableValue<Integer> |
anchorProperty() |
ObservableBooleanValue |
beingUpdatedProperty() |
ObservableValue<Integer> |
caretColumnProperty() |
ObservableValue<Integer> |
caretPositionProperty() |
void |
clearParagraphStyle(int paragraph)
Resets the style of the given paragraph to the initial style.
|
void |
clearStyle(int paragraph)
Resets the style of the given paragraph to the initial style.
|
void |
clearStyle(int from,
int to)
Resets the style of the given range to the initial style.
|
void |
clearStyle(int paragraph,
int from,
int to)
Resets the style of the given range in the given paragraph
to the initial style.
|
ObservableValue<Integer> |
currentParagraphProperty() |
void |
dispose() |
BooleanProperty |
editableProperty()
Indicates whether this text area can be edited by the user.
|
org.reactfx.value.Var<Double> |
estimatedScrollXProperty()
The estimated scrollX value.
|
org.reactfx.value.Var<Double> |
estimatedScrollYProperty()
The estimated scrollY value.
|
int |
getAbsolutePosition(int paragraphIndex,
int columnIndex)
Returns the absolute position (i.e.
|
int |
getAnchor()
Gets the value of the property anchor.
|
BiConsumer<TextFlow,PS> |
getApplyParagraphStyle() |
BiConsumer<? super TextExt,S> |
getApplyStyle() |
int |
getCaretColumn()
Gets the value of the property caretColumn.
|
int |
getCaretPosition()
Gets the value of the property caretPosition.
|
EditableStyledDocument<PS,S> |
getContent()
The underlying document that can be displayed by multiple
StyledTextAreas. |
int |
getCurrentParagraph()
Gets the value of the property currentParagraph.
|
StyledDocument<PS,S> |
getDocument()
Rich-text content of this text-editing area.
|
double |
getEstimatedScrollX()
Gets the value of the property estimatedScrollX.
|
double |
getEstimatedScrollY()
Gets the value of the property estimatedScrollY.
|
PS |
getInitialParagraphStyle()
Style used by default when no other style is provided.
|
S |
getInitialTextStyle()
Style used by default when no other style is provided.
|
int |
getLength()
Gets the value of the property length.
|
Duration |
getMouseOverTextDelay()
Gets the value of the property mouseOverTextDelay.
|
IntConsumer |
getOnSelectionDrop() |
Paragraph<PS,S> |
getParagraph(int index) |
IntFunction<? extends Node> |
getParagraphGraphicFactory()
Gets the value of the property paragraphGraphicFactory.
|
org.reactfx.collection.LiveList<Paragraph<PS,S>> |
getParagraphs()
Unmodifiable observable list of paragraphs in this text area.
|
IndexRange |
getParagraphSelection(int paragraph)
Returns the selection range in the given paragraph.
|
PopupAlignment |
getPopupAlignment()
Gets the value of the property popupAlignment.
|
UnaryOperator<Point2D> |
getPopupAnchorAdjustment()
Gets the value of the property popupAnchorAdjustment.
|
Point2D |
getPopupAnchorOffset()
Gets the value of the property popupAnchorOffset.
|
PopupWindow |
getPopupAtCaret()
Deprecated.
Use
getPopupWindow(). |
PopupWindow |
getPopupWindow()
Gets the value of the property popupWindow.
|
String |
getSelectedText()
Gets the value of the property selectedText.
|
IndexRange |
getSelection()
Gets the value of the property selection.
|
StyledTextArea.CaretVisibility |
getShowCaret()
Gets the value of the property showCaret.
|
S |
getStyleAtPosition(int position)
Returns the style at the given position.
|
S |
getStyleAtPosition(int paragraph,
int position)
Returns the style at the given position in the given paragraph.
|
Optional<org.reactfx.util.Tuple2<Codec<PS>,Codec<S>>> |
getStyleCodecs() |
S |
getStyleOfChar(int index)
Returns the style of the character with the given index.
|
S |
getStyleOfChar(int paragraph,
int index)
Returns the style of the character with the given index in the given
paragraph.
|
IndexRange |
getStyleRangeAtPosition(int position)
Returns the range of homogeneous style that includes the given position.
|
IndexRange |
getStyleRangeAtPosition(int paragraph,
int position)
Returns the range of homogeneous style that includes the given position
in the given paragraph.
|
StyleSpans<S> |
getStyleSpans(IndexRange range)
Returns the styles in the given character range.
|
StyleSpans<S> |
getStyleSpans(int paragraph)
Returns styles of the whole paragraph.
|
StyleSpans<S> |
getStyleSpans(int paragraph,
IndexRange range)
Returns the styles in the given character range of the given paragraph.
|
StyleSpans<S> |
getStyleSpans(int from,
int to)
Returns the styles in the given character range.
|
StyleSpans<S> |
getStyleSpans(int paragraph,
int from,
int to)
Returns the styles in the given character range of the given paragraph.
|
String |
getText()
Gets the value of the property text.
|
String |
getText(int paragraph)
Returns text content of the given paragraph.
|
String |
getText(int start,
int end)
Returns text content of the given character range.
|
double |
getTotalHeightEstimate()
Gets the value of the property totalHeightEstimate.
|
double |
getTotalWidthEstimate()
Gets the value of the property totalWidthEstimate.
|
org.fxmisc.undo.UndoManager |
getUndoManager()
Undo manager of this text area.
|
boolean |
getUseInitialStyleForInsertion()
Gets the value of the property useInitialStyleForInsertion.
|
CharacterHit |
hit(double x,
double y)
Helpful for determining which letter is at point x, y:
|
boolean |
isBeingUpdated() |
boolean |
isEditable()
Gets the value of the property editable.
|
boolean |
isPreserveStyle()
Indicates whether style should be preserved on undo/redo,
copy/paste and text move.
|
boolean |
isWrapText()
Gets the value of the property wrapText.
|
protected void |
layoutChildren() |
ObservableValue<Integer> |
lengthProperty() |
ObjectProperty<Duration> |
mouseOverTextDelayProperty()
Defines how long the mouse has to stay still over the text before a
MouseOverTextEvent of type MOUSE_OVER_TEXT_BEGIN is
fired on this text area. |
TwoDimensional.Position |
offsetToPosition(int charOffset,
TwoDimensional.Bias bias) |
ObjectProperty<IntFunction<? extends Node>> |
paragraphGraphicFactoryProperty() |
org.reactfx.EventStream<PlainTextChange> |
plainTextChanges()
Stream of text changes.
|
ObjectProperty<PopupAlignment> |
popupAlignmentProperty()
Defines where the popup window given in
popupWindowProperty()
is anchored, i.e. |
ObjectProperty<UnaryOperator<Point2D>> |
popupAnchorAdjustmentProperty()
Specifies how to adjust the popup window's anchor point.
|
ObjectProperty<Point2D> |
popupAnchorOffsetProperty()
Specifies further offset (in pixels) of the popup window from the
position specified by
popupAlignmentProperty(). |
ObjectProperty<PopupWindow> |
popupAtCaretProperty()
Deprecated.
|
ObjectProperty<PopupWindow> |
popupWindowProperty()
Popup window that will be positioned by this text area relative to the
caret or selection.
|
TwoDimensional.Position |
position(int row,
int col) |
void |
positionCaret(int pos)
Deprecated.
You probably meant to use
NavigationActions.moveTo(int). This method will be made
package-private in the future |
void |
replace(int start,
int end,
StyledDocument<PS,S> replacement)
Replaces a range of characters with the given rich-text document.
|
void |
replaceText(int start,
int end,
String text)
Replaces a range of characters with the given text.
|
org.reactfx.EventStream<RichTextChange<PS,S>> |
richChanges()
Stream of rich text changes.
|
ObservableValue<String> |
selectedTextProperty() |
ObservableValue<IndexRange> |
selectionProperty() |
void |
selectRange(int anchor,
int caretPosition)
Positions the anchor and caretPosition explicitly,
effectively creating a selection.
|
void |
setEditable(boolean value)
Sets the value of the property editable.
|
void |
setEstimatedScrollX(double value)
Sets the value of the property estimatedScrollX.
|
void |
setEstimatedScrollY(double value)
Sets the value of the property estimatedScrollY.
|
void |
setMouseOverTextDelay(Duration delay)
Sets the value of the property mouseOverTextDelay.
|
void |
setOnSelectionDrop(IntConsumer consumer) |
void |
setParagraphGraphicFactory(IntFunction<? extends Node> factory)
Sets the value of the property paragraphGraphicFactory.
|
void |
setParagraphStyle(int paragraph,
PS paragraphStyle)
Sets style for the whole paragraph.
|
void |
setPopupAlignment(PopupAlignment pos)
Sets the value of the property popupAlignment.
|
void |
setPopupAnchorAdjustment(UnaryOperator<Point2D> f)
Sets the value of the property popupAnchorAdjustment.
|
void |
setPopupAnchorOffset(Point2D offset)
Sets the value of the property popupAnchorOffset.
|
void |
setPopupAtCaret(PopupWindow popup)
Deprecated.
|
void |
setPopupWindow(PopupWindow popup)
Sets the value of the property popupWindow.
|
void |
setShowCaret(StyledTextArea.CaretVisibility value)
Sets the value of the property showCaret.
|
void |
setStyle(int paragraph,
int from,
int to,
S style)
Sets style for the given range relative in the given paragraph.
|
void |
setStyle(int from,
int to,
S style)
Sets style for the given character range.
|
void |
setStyle(int paragraph,
S style)
Sets style for the whole paragraph.
|
void |
setStyleCodecs(Codec<PS> paragraphStyleCodec,
Codec<S> textStyleCodec)
Sets codecs to encode/decode style information to/from binary format.
|
void |
setStyleSpans(int paragraph,
int from,
StyleSpans<? extends S> styleSpans)
Set multiple style ranges of a paragraph at once.
|
void |
setStyleSpans(int from,
StyleSpans<? extends S> styleSpans)
Set multiple style ranges at once.
|
void |
setUndoManager(org.fxmisc.undo.UndoManagerFactory undoManagerFactory) |
void |
setUseInitialStyleForInsertion(boolean value)
Sets the value of the property useInitialStyleForInsertion.
|
void |
setWrapText(boolean value)
Sets the value of the property wrapText.
|
org.reactfx.value.Var<StyledTextArea.CaretVisibility> |
showCaretProperty()
Indicates when this text area should display a caret.
|
StyledDocument<PS,S> |
subDocument(int paragraphIndex)
Returns rich-text content of the given paragraph.
|
StyledDocument<PS,S> |
subDocument(int start,
int end)
Returns rich-text content of the given character range.
|
ObservableValue<String> |
textProperty() |
org.reactfx.value.Val<Double> |
totalHeightEstimateProperty()
The estimated height of the entire document.
|
org.reactfx.value.Val<Double> |
totalWidthEstimateProperty()
The estimated width of the entire document.
|
BooleanProperty |
useInitialStyleForInsertionProperty()
Indicates whether the initial style should also be used for plain text
inserted into this text area.
|
BooleanProperty |
wrapTextProperty()
When a run of text exceeds the width of the text region,
then this property indicates whether the text should wrap
onto another line.
|
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, 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, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapSize, snapSpace, snapToPixelProperty, widthPropertygetBaselineOffset, getChildren, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processCSS, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBoundsaccessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, 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, hasProperties, hoverProperty, idProperty, impl_clearDirty, impl_computeIntersects, impl_cssGetCursorInitialValue, impl_cssGetFocusTraversableInitialValue, impl_findStyles, impl_geomChanged, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, 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, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visiblePropertyclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcopy, cut, pasteappend, appendText, clear, deleteNextChar, deletePreviousChar, deleteText, deleteText, deleteText, insert, insert, insertText, insertText, moveSelectedText, replace, replaceSelection, replaceSelection, replaceTextgetText, replace, replace, replaceText, replaceText, selectRange, subDocumentdeselect, end, lineEnd, lineStart, moveTo, moveTo, moveTo, moveTo, nextChar, previousChar, selectAll, selectLine, start, wordBreaksBackwards, wordBreaksForwardsisRedoAvailable, isUndoAvailable, redo, redoAvailableProperty, undo, undoAvailablePropertypublic final BooleanProperty editableProperty
isEditable(),
setEditable(boolean)public final BooleanProperty wrapTextProperty
isWrapText(),
setWrapText(boolean)public final org.reactfx.value.Var<StyledTextArea.CaretVisibility> showCaretProperty
getShowCaret(),
setShowCaret(CaretVisibility)public ObjectProperty<PopupWindow> popupWindowProperty
popupAlignmentProperty() to specify
how the popup should be positioned relative to the caret or selection.
Use popupAnchorOffsetProperty() or
popupAnchorAdjustmentProperty() to further adjust the position.getPopupWindow(),
setPopupWindow(PopupWindow)@Deprecated public ObjectProperty<PopupWindow> popupAtCaretProperty
getPopupAtCaret(),
setPopupAtCaret(PopupWindow)public ObjectProperty<Point2D> popupAnchorOffsetProperty
popupAlignmentProperty().
If popupAnchorAdjustmentProperty() is also specified, then
it overrides the offset set by this property.
public ObjectProperty<UnaryOperator<Point2D>> popupAnchorAdjustmentProperty
popupAlignmentProperty() and should return a new screen
position. This position will be used as the popup window's anchor point.
Setting this property overrides popupAnchorOffsetProperty().
public ObjectProperty<PopupAlignment> popupAlignmentProperty
popupWindowProperty()
is anchored, i.e. where its anchor point is positioned. This position
can further be adjusted by popupAnchorOffsetProperty() or
popupAnchorAdjustmentProperty().public ObjectProperty<Duration> mouseOverTextDelayProperty
MouseOverTextEvent of type MOUSE_OVER_TEXT_BEGIN is
fired on this text area. When set to null, no
MouseOverTextEvents are fired on this text area.
Default value is null.
public ObjectProperty<IntFunction<? extends Node>> paragraphGraphicFactoryProperty
public BooleanProperty useInitialStyleForInsertionProperty
false, the style immediately
preceding the insertion position is used. Default value is false.public org.reactfx.value.Var<Double> estimatedScrollXProperty
estimatedScrollXProperty in interface org.fxmisc.flowless.VirtualizedgetEstimatedScrollX(),
setEstimatedScrollX(double)public org.reactfx.value.Var<Double> estimatedScrollYProperty
estimatedScrollYProperty in interface org.fxmisc.flowless.VirtualizedgetEstimatedScrollY(),
setEstimatedScrollY(double)public final ObservableValue<String> textProperty
textProperty in interface TextEditingArea<PS,S>getText()public final ObservableValue<Integer> lengthProperty
lengthProperty in interface TextEditingArea<PS,S>getLength()public final ObservableValue<Integer> caretPositionProperty
caretPositionProperty in interface TextEditingArea<PS,S>getCaretPosition()public final ObservableValue<Integer> anchorProperty
anchorProperty in interface TextEditingArea<PS,S>getAnchor()public final ObservableValue<IndexRange> selectionProperty
selectionProperty in interface TextEditingArea<PS,S>getSelection()public final ObservableValue<String> selectedTextProperty
selectedTextProperty in interface TextEditingArea<PS,S>getSelectedText()public final ObservableValue<Integer> currentParagraphProperty
currentParagraphProperty in interface TextEditingArea<PS,S>getCurrentParagraph()public final ObservableValue<Integer> caretColumnProperty
caretColumnProperty in interface TextEditingArea<PS,S>getCaretColumn()public ObservableBooleanValue beingUpdatedProperty
public org.reactfx.value.Val<Double> totalWidthEstimateProperty
totalWidthEstimateProperty in interface org.fxmisc.flowless.VirtualizedgetTotalWidthEstimate()public org.reactfx.value.Val<Double> totalHeightEstimateProperty
totalHeightEstimateProperty in interface org.fxmisc.flowless.VirtualizedgetTotalHeightEstimate()public static final IndexRange EMPTY_RANGE
public StyledTextArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, BiConsumer<? super TextExt,S> applyStyle)
initialTextStyle - style to use in places where no other style is
specified (yet).applyStyle - function that, given a Text node and
a style, applies the style to the text node. This function is
used by the default skin to apply style to text nodes.initialParagraphStyle - style to use in places where no other style is
specified (yet).applyParagraphStyle - function that, given a TextFlow node and
a style, applies the style to the paragraph node. This function is
used by the default skin to apply style to paragraph nodes.public StyledTextArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, BiConsumer<? super TextExt,S> applyStyle, boolean preserveStyle)
public StyledTextArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, BiConsumer<? super TextExt,S> applyStyle, EditableStyledDocument<PS,S> document)
StyledTextArea(Object, BiConsumer, Object, BiConsumer) except that
this constructor can be used to create another StyledTextArea object that
shares the same EditableStyledDocument.public StyledTextArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, BiConsumer<? super TextExt,S> applyStyle, EditableStyledDocument<PS,S> document, boolean preserveStyle)
public final boolean isEditable()
public final void setEditable(boolean value)
public final BooleanProperty editableProperty()
isEditable(),
setEditable(boolean)public final boolean isWrapText()
public final void setWrapText(boolean value)
public final BooleanProperty wrapTextProperty()
isWrapText(),
setWrapText(boolean)public final StyledTextArea.CaretVisibility getShowCaret()
public final void setShowCaret(StyledTextArea.CaretVisibility value)
public final org.reactfx.value.Var<StyledTextArea.CaretVisibility> showCaretProperty()
getShowCaret(),
setShowCaret(CaretVisibility)public org.fxmisc.undo.UndoManager getUndoManager()
UndoActionsgetUndoManager in interface UndoActionspublic void setUndoManager(org.fxmisc.undo.UndoManagerFactory undoManagerFactory)
setUndoManager in interface UndoActionspublic void setPopupWindow(PopupWindow popup)
popupAlignmentProperty() to specify
how the popup should be positioned relative to the caret or selection.
Use popupAnchorOffsetProperty() or
popupAnchorAdjustmentProperty() to further adjust the position.public PopupWindow getPopupWindow()
popupAlignmentProperty() to specify
how the popup should be positioned relative to the caret or selection.
Use popupAnchorOffsetProperty() or
popupAnchorAdjustmentProperty() to further adjust the position.public ObjectProperty<PopupWindow> popupWindowProperty()
popupAlignmentProperty() to specify
how the popup should be positioned relative to the caret or selection.
Use popupAnchorOffsetProperty() or
popupAnchorAdjustmentProperty() to further adjust the position.getPopupWindow(),
setPopupWindow(PopupWindow)@Deprecated public void setPopupAtCaret(PopupWindow popup)
setPopupWindow(PopupWindow).@Deprecated public PopupWindow getPopupAtCaret()
getPopupWindow().@Deprecated public ObjectProperty<PopupWindow> popupAtCaretProperty()
getPopupAtCaret(),
setPopupAtCaret(PopupWindow)public void setPopupAnchorOffset(Point2D offset)
popupAlignmentProperty().
If popupAnchorAdjustmentProperty() is also specified, then
it overrides the offset set by this property.
public Point2D getPopupAnchorOffset()
popupAlignmentProperty().
If popupAnchorAdjustmentProperty() is also specified, then
it overrides the offset set by this property.
public ObjectProperty<Point2D> popupAnchorOffsetProperty()
popupAlignmentProperty().
If popupAnchorAdjustmentProperty() is also specified, then
it overrides the offset set by this property.
public void setPopupAnchorAdjustment(UnaryOperator<Point2D> f)
popupAlignmentProperty() and should return a new screen
position. This position will be used as the popup window's anchor point.
Setting this property overrides popupAnchorOffsetProperty().
public UnaryOperator<Point2D> getPopupAnchorAdjustment()
popupAlignmentProperty() and should return a new screen
position. This position will be used as the popup window's anchor point.
Setting this property overrides popupAnchorOffsetProperty().
public ObjectProperty<UnaryOperator<Point2D>> popupAnchorAdjustmentProperty()
popupAlignmentProperty() and should return a new screen
position. This position will be used as the popup window's anchor point.
Setting this property overrides popupAnchorOffsetProperty().
public void setPopupAlignment(PopupAlignment pos)
popupWindowProperty()
is anchored, i.e. where its anchor point is positioned. This position
can further be adjusted by popupAnchorOffsetProperty() or
popupAnchorAdjustmentProperty().public PopupAlignment getPopupAlignment()
popupWindowProperty()
is anchored, i.e. where its anchor point is positioned. This position
can further be adjusted by popupAnchorOffsetProperty() or
popupAnchorAdjustmentProperty().public ObjectProperty<PopupAlignment> popupAlignmentProperty()
popupWindowProperty()
is anchored, i.e. where its anchor point is positioned. This position
can further be adjusted by popupAnchorOffsetProperty() or
popupAnchorAdjustmentProperty().public void setMouseOverTextDelay(Duration delay)
MouseOverTextEvent of type MOUSE_OVER_TEXT_BEGIN is
fired on this text area. When set to null, no
MouseOverTextEvents are fired on this text area.
Default value is null.
public Duration getMouseOverTextDelay()
MouseOverTextEvent of type MOUSE_OVER_TEXT_BEGIN is
fired on this text area. When set to null, no
MouseOverTextEvents are fired on this text area.
Default value is null.
public ObjectProperty<Duration> mouseOverTextDelayProperty()
MouseOverTextEvent of type MOUSE_OVER_TEXT_BEGIN is
fired on this text area. When set to null, no
MouseOverTextEvents are fired on this text area.
Default value is null.
public final void setOnSelectionDrop(IntConsumer consumer)
public final IntConsumer getOnSelectionDrop()
public void setParagraphGraphicFactory(IntFunction<? extends Node> factory)
public IntFunction<? extends Node> getParagraphGraphicFactory()
public ObjectProperty<IntFunction<? extends Node>> paragraphGraphicFactoryProperty()
public BooleanProperty useInitialStyleForInsertionProperty()
false, the style immediately
preceding the insertion position is used. Default value is false.public void setUseInitialStyleForInsertion(boolean value)
false, the style immediately
preceding the insertion position is used. Default value is false.public boolean getUseInitialStyleForInsertion()
false, the style immediately
preceding the insertion position is used. Default value is false.public void setStyleCodecs(Codec<PS> paragraphStyleCodec, Codec<S> textStyleCodec)
public Optional<org.reactfx.util.Tuple2<Codec<PS>,Codec<S>>> getStyleCodecs()
getStyleCodecs in interface ClipboardActions<PS,S>public org.reactfx.value.Var<Double> estimatedScrollXProperty()
estimatedScrollXProperty in interface org.fxmisc.flowless.VirtualizedgetEstimatedScrollX(),
setEstimatedScrollX(double)public double getEstimatedScrollX()
public void setEstimatedScrollX(double value)
public org.reactfx.value.Var<Double> estimatedScrollYProperty()
estimatedScrollYProperty in interface org.fxmisc.flowless.VirtualizedgetEstimatedScrollY(),
setEstimatedScrollY(double)public double getEstimatedScrollY()
public void setEstimatedScrollY(double value)
public final String getText()
getText in interface TextEditingArea<PS,S>public final ObservableValue<String> textProperty()
textProperty in interface TextEditingArea<PS,S>getText()public final StyledDocument<PS,S> getDocument()
TextEditingAreagetDocument in interface TextEditingArea<PS,S>public final int getLength()
getLength in interface TextEditingArea<PS,S>public final ObservableValue<Integer> lengthProperty()
lengthProperty in interface TextEditingArea<PS,S>getLength()public final int getCaretPosition()
getCaretPosition in interface TextEditingArea<PS,S>public final ObservableValue<Integer> caretPositionProperty()
caretPositionProperty in interface TextEditingArea<PS,S>getCaretPosition()public final int getAnchor()
getAnchor in interface TextEditingArea<PS,S>public final ObservableValue<Integer> anchorProperty()
anchorProperty in interface TextEditingArea<PS,S>getAnchor()public final IndexRange getSelection()
getSelection in interface TextEditingArea<PS,S>public final ObservableValue<IndexRange> selectionProperty()
selectionProperty in interface TextEditingArea<PS,S>getSelection()public final String getSelectedText()
getSelectedText in interface TextEditingArea<PS,S>public final ObservableValue<String> selectedTextProperty()
selectedTextProperty in interface TextEditingArea<PS,S>getSelectedText()public final int getCurrentParagraph()
getCurrentParagraph in interface TextEditingArea<PS,S>public final ObservableValue<Integer> currentParagraphProperty()
currentParagraphProperty in interface TextEditingArea<PS,S>getCurrentParagraph()public final int getCaretColumn()
getCaretColumn in interface TextEditingArea<PS,S>public final ObservableValue<Integer> caretColumnProperty()
caretColumnProperty in interface TextEditingArea<PS,S>getCaretColumn()public org.reactfx.collection.LiveList<Paragraph<PS,S>> getParagraphs()
TextEditingAreagetParagraphs in interface TextEditingArea<PS,S>public ObservableBooleanValue beingUpdatedProperty()
public boolean isBeingUpdated()
public org.reactfx.value.Val<Double> totalWidthEstimateProperty()
totalWidthEstimateProperty in interface org.fxmisc.flowless.VirtualizedgetTotalWidthEstimate()public double getTotalWidthEstimate()
public org.reactfx.value.Val<Double> totalHeightEstimateProperty()
totalHeightEstimateProperty in interface org.fxmisc.flowless.VirtualizedgetTotalHeightEstimate()public double getTotalHeightEstimate()
public final org.reactfx.EventStream<PlainTextChange> plainTextChanges()
TextEditingAreaplainTextChanges in interface TextEditingArea<PS,S>public final org.reactfx.EventStream<RichTextChange<PS,S>> richChanges()
TextEditingArearichChanges in interface TextEditingArea<PS,S>public final EditableStyledDocument<PS,S> getContent()
StyledTextAreas.public final S getInitialTextStyle()
public final PS getInitialParagraphStyle()
public final BiConsumer<? super TextExt,S> getApplyStyle()
public final BiConsumer<TextFlow,PS> getApplyParagraphStyle()
public final boolean isPreserveStyle()
public CharacterHit hit(double x, double y)
StyledTextArea area = // creation code
area.addEventHandler(MouseEvent.MOUSE_PRESSED, (MouseEvent e) -> {
CharacterHit hit = area.hit(e.getX(), e.getY());
int characterPosition = hit.getInsertionIndex();
// move the caret to that character's position
area.moveTo(characterPosition, SelectionPolicy.CLEAR);
}
public final String getText(int start, int end)
TextEditingAreagetText in interface TextEditingArea<PS,S>public String getText(int paragraph)
TextEditingAreagetText in interface TextEditingArea<PS,S>public StyledDocument<PS,S> subDocument(int start, int end)
TextEditingAreasubDocument in interface TextEditingArea<PS,S>public StyledDocument<PS,S> subDocument(int paragraphIndex)
TextEditingAreasubDocument in interface TextEditingArea<PS,S>public IndexRange getParagraphSelection(int paragraph)
public S getStyleOfChar(int index)
index points to a line terminator character,
the last style used in the paragraph terminated by that
line terminator is returned.public S getStyleAtPosition(int position)
position, except when
position points to a paragraph boundary, in which case it
is the style at the beginning of the latter paragraph.
In other words, most of the time getStyleAtPosition(p)
is equivalent to getStyleOfChar(p-1), except when p
points to a paragraph boundary, in which case it is equivalent to
getStyleOfChar(p).
public IndexRange getStyleRangeAtPosition(int position)
position points to a boundary between two styled ranges, then
the range preceding position is returned. If position
points to a boundary between two paragraphs, then the first styled range
of the latter paragraph is returned.public StyleSpans<S> getStyleSpans(int from, int to)
public StyleSpans<S> getStyleSpans(IndexRange range)
public S getStyleOfChar(int paragraph, int index)
index is beyond the end of the paragraph, the
style at the end of line is returned. If index is negative, it
is the same as if it was 0.public S getStyleAtPosition(int paragraph, int position)
getStyleOfChar(paragraph, position-1).public IndexRange getStyleRangeAtPosition(int paragraph, int position)
position points to a boundary between
two styled ranges, then the range preceding position is returned.public StyleSpans<S> getStyleSpans(int paragraph)
public StyleSpans<S> getStyleSpans(int paragraph, int from, int to)
public StyleSpans<S> getStyleSpans(int paragraph, IndexRange range)
public int getAbsolutePosition(int paragraphIndex,
int columnIndex)
TextEditingAreaFor example, given a text with only one line "text" and the columnIndex value of 1, "position 1" would be returned:
┌ character index 0 | ┌ character index 1 | | ┌ character index 3 | | | v v v |t|e|x|t| ^ ^ ^ | | | | | └ position 4 | └ position 1 └ position 0
If the column index spans outside of the given paragraph's length, the returned value will pass on to the previous/next paragraph. In other words, given a document with two paragraphs (where the first paragraph's text is "some" and the second "thing"), then the following statements are true:
getAbsolutePosition(0, "some".length()) == 4 == getAbsolutePosition(1, -1)getAbsolutePosition(0, "some".length() + 1) == 5 == getAbsolutePosition(1, 0)getAbsolutePosition in interface TextEditingArea<PS,S>paragraphIndex - The index of the paragraph from which to start.columnIndex - If positive, the index going forward (the given paragraph's line or the next one(s)).
If negative, the index going backward (the previous paragraph's line(s)public TwoDimensional.Position position(int row, int col)
position in interface TwoDimensionalpublic TwoDimensional.Position offsetToPosition(int charOffset, TwoDimensional.Bias bias)
offsetToPosition in interface TwoDimensionalpublic void setStyle(int from,
int to,
S style)
public void setStyle(int paragraph,
S style)
public void setStyle(int paragraph,
int from,
int to,
S style)
public void setStyleSpans(int from,
StyleSpans<? extends S> styleSpans)
for(StyleSpan <S> span: styleSpans) {
setStyle(from, from + span.getLength(), span.getStyle());
from += span.getLength();
}
but the actual implementation is more efficient.public void setStyleSpans(int paragraph,
int from,
StyleSpans<? extends S> styleSpans)
for(StyleSpan <S> span: styleSpans) {
setStyle(paragraph, from, from + span.getLength(), span.getStyle());
from += span.getLength();
}
but the actual implementation is more efficient.public void setParagraphStyle(int paragraph,
PS paragraphStyle)
public void clearStyle(int from,
int to)
public void clearStyle(int paragraph)
public void clearStyle(int paragraph,
int from,
int to)
public void clearParagraphStyle(int paragraph)
public void replaceText(int start,
int end,
String text)
TextEditingArea0 <= start <= end <= getLength().replaceText in interface TextEditingArea<PS,S>start - Start index of the range to replace, inclusive.end - End index of the range to replace, exclusive.text - The text to put in place of the deleted range.
It must not be null.public void replace(int start,
int end,
StyledDocument<PS,S> replacement)
TextEditingAreareplace in interface TextEditingArea<PS,S>public void selectRange(int anchor,
int caretPosition)
TextEditingAreaselectRange in interface TextEditingArea<PS,S>@Deprecated public void positionCaret(int pos)
NavigationActions.moveTo(int). This method will be made
package-private in the futurepositionCaret in interface TextEditingArea<PS,S>public void dispose()
protected void layoutChildren()
layoutChildren in class Parent