@DefaultProperty(value="text") public class Text extends Shape
Text
class defines a node that displays a text.
Paragraphs are separated by '\n'
and the text is wrapped on
paragraph boundaries.
import javafx.scene.text.*; Text t = new Text(10, 50, "This is a test"); t.setFont(new Font(20));
import javafx.scene.text.*; Text t = new Text(); text.setFont(new Font(20)); text.setText("First row\nSecond row");
import javafx.scene.text.*; Text t = new Text(); text.setFont(new Font(20)); text.setWrappingWidth(200); text.setTextAlignment(TextAlignment.JUSTIFY) text.setText("The quick brown fox jumps over the lazy dog");
BASELINE_OFFSET_SAME_AS_HEIGHT
Constructor and Description |
---|
Text()
Creates an empty instance of Text.
|
Text(double x,
double y,
String text)
Creates an instance of Text on the given coordinates containing the
given string.
|
Text(String text)
Creates an instance of Text containing the given string.
|
Modifier and Type | Method and Description |
---|---|
ReadOnlyDoubleProperty |
baselineOffsetProperty()
The 'alphabetic' (or roman) baseline offset from the Text node's
layoutBounds.minY location.
|
ObjectProperty<TextBoundsType> |
boundsTypeProperty() |
ObjectProperty<Font> |
fontProperty() |
ObjectProperty<FontSmoothingType> |
fontSmoothingTypeProperty() |
double |
getBaselineOffset()
The 'alphabetic' (or 'roman') baseline offset from the node's layoutBounds.minY location
that should be used when this node is being vertically aligned by baseline with
other nodes.
|
TextBoundsType |
getBoundsType() |
static List<CssMetaData<? extends Styleable,?>> |
getClassCssMetaData() |
List<CssMetaData<? extends Styleable,?>> |
getCssMetaData()
This method should delegate to
Node.getClassCssMetaData() so that
a Node's CssMetaData can be accessed without the need for reflection. |
Font |
getFont() |
FontSmoothingType |
getFontSmoothingType() |
int |
getImpl_caretPosition()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
PathElement[] |
getImpl_caretShape()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
int |
getImpl_selectionEnd()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
PathElement[] |
getImpl_selectionShape()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
int |
getImpl_selectionStart()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
double |
getLineSpacing() |
String |
getText() |
TextAlignment |
getTextAlignment() |
VPos |
getTextOrigin() |
double |
getWrappingWidth() |
double |
getX() |
double |
getY() |
BooleanProperty |
impl_caretBiasProperty()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
IntegerProperty |
impl_caretPositionProperty()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
ReadOnlyObjectProperty<PathElement[]> |
impl_caretShapeProperty()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
protected boolean |
impl_computeContains(double localX,
double localY)
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
BaseBounds |
impl_computeGeomBounds(BaseBounds bounds,
BaseTransform tx)
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
protected Bounds |
impl_computeLayoutBounds()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
Shape |
impl_configShape()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
protected NGNode |
impl_createPeer()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
void |
impl_displaySoftwareKeyboard(boolean display)
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
protected void |
impl_geomChanged()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
PathElement[] |
impl_getRangeShape(int start,
int end)
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
PathElement[] |
impl_getUnderlineShape(int start,
int end)
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
HitInfo |
impl_hitTestChar(Point2D point)
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
IntegerProperty |
impl_selectionEndProperty()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
ObjectProperty<Paint> |
impl_selectionFillProperty()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
ReadOnlyObjectProperty<PathElement[]> |
impl_selectionShapeProperty()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
IntegerProperty |
impl_selectionStartProperty()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
void |
impl_updatePeer()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
boolean |
isImpl_caretBias()
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
boolean |
isStrikethrough() |
boolean |
isUnderline() |
DoubleProperty |
lineSpacingProperty()
Defines the vertical space in pixel between lines.
|
Object |
queryAccessibleAttribute(AccessibleAttribute attribute,
Object... parameters)
This method is called by the assistive technology to request
the value for an attribute.
|
void |
setBoundsType(TextBoundsType value) |
void |
setFont(Font value) |
void |
setFontSmoothingType(FontSmoothingType value) |
void |
setImpl_caretBias(boolean value)
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
void |
setImpl_caretPosition(int value)
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
void |
setImpl_selectionEnd(int value)
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
void |
setImpl_selectionStart(int value)
Deprecated.
This is an internal API that is not intended
for use and will be removed in the next version
|
void |
setLineSpacing(double spacing) |
void |
setStrikethrough(boolean value) |
void |
setText(String value) |
void |
setTextAlignment(TextAlignment value) |
void |
setTextOrigin(VPos value) |
void |
setUnderline(boolean value) |
void |
setWrappingWidth(double value) |
void |
setX(double value) |
void |
setY(double value) |
BooleanProperty |
strikethroughProperty()
Defines if each line of text should have a line through it.
|
ObjectProperty<TextAlignment> |
textAlignmentProperty()
Defines horizontal text alignment in the bounding box.
|
ObjectProperty<VPos> |
textOriginProperty()
Defines the origin of text coordinate system in local coordinates.
|
StringProperty |
textProperty() |
String |
toString()
Returns a string representation of this
Text object. |
BooleanProperty |
underlineProperty()
Defines if each line of text should have a line below it.
|
boolean |
usesMirroring()
Determines whether a node should be mirrored when node orientation
is right-to-left.
|
DoubleProperty |
wrappingWidthProperty() |
DoubleProperty |
xProperty() |
DoubleProperty |
yProperty() |
fillProperty, getFill, getStroke, getStrokeDashArray, getStrokeDashOffset, getStrokeLineCap, getStrokeLineJoin, getStrokeMiterLimit, getStrokeType, getStrokeWidth, impl_cssGetFillInitialValue, impl_cssGetStrokeInitialValue, impl_markDirty, impl_processMXNode, impl_setShapeChangeListener, intersect, isSmooth, setFill, setSmooth, setStroke, setStrokeDashOffset, setStrokeLineCap, setStrokeLineJoin, setStrokeMiterLimit, setStrokeType, setStrokeWidth, smoothProperty, strokeDashOffsetProperty, strokeLineCapProperty, strokeLineJoinProperty, strokeMiterLimitProperty, strokeProperty, strokeTypeProperty, strokeWidthProperty, subtract, union
accessibleHelpProperty, 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_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_notifyLayoutBoundsChanged, impl_pickNode, impl_pickNodeLocal, impl_processCSS, 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, isResizable, 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, lookup, lookupAll, managedProperty, maxHeight, maxWidth, minHeight, minWidth, 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, prefHeight, prefWidth, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resize, 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, translateXProperty, translateYProperty, translateZProperty, visibleProperty
public Text()
public Text(String text)
text
- text to be contained in the instancepublic Text(double x, double y, String text)
x
- the horizontal position of the texty
- the vertical position of the texttext
- text to be contained in the instance@Deprecated protected final NGNode impl_createPeer()
impl_createPeer
in class Shape
public boolean usesMirroring()
Node
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 false
and implement right-to-left
orientation without using the automatic transformation.
usesMirroring
in class Node
public final void setText(String value)
public final String getText()
public final StringProperty textProperty()
public final void setX(double value)
public final double getX()
public final DoubleProperty xProperty()
public final void setY(double value)
public final double getY()
public final DoubleProperty yProperty()
public final void setFont(Font value)
public final Font getFont()
public final ObjectProperty<Font> fontProperty()
public final void setTextOrigin(VPos value)
public final VPos getTextOrigin()
public final ObjectProperty<VPos> textOriginProperty()
VPos.BASELINE
and
VPos.TOP
define the origin of the top row while
VPos.BOTTOM
defines the origin of the bottom row.public final void setBoundsType(TextBoundsType value)
public final TextBoundsType getBoundsType()
public final ObjectProperty<TextBoundsType> boundsTypeProperty()
public final void setWrappingWidth(double value)
public final double getWrappingWidth()
public final DoubleProperty wrappingWidthProperty()
public final void setUnderline(boolean value)
public final boolean isUnderline()
public final BooleanProperty underlineProperty()
public final void setStrikethrough(boolean value)
public final boolean isStrikethrough()
public final BooleanProperty strikethroughProperty()
public final void setTextAlignment(TextAlignment value)
public final TextAlignment getTextAlignment()
public final ObjectProperty<TextAlignment> textAlignmentProperty()
public final void setLineSpacing(double spacing)
public final double getLineSpacing()
public final DoubleProperty lineSpacingProperty()
public final double getBaselineOffset()
Node
Node.BASELINE_OFFSET_SAME_AS_HEIGHT
for resizable Nodes
and layoutBounds height for non-resizable. Subclasses
which contain text should override this method to return their actual text baseline offset.getBaselineOffset
in class Node
Node.BASELINE_OFFSET_SAME_AS_HEIGHT
otherwisepublic final ReadOnlyDoubleProperty baselineOffsetProperty()
public final void setFontSmoothingType(FontSmoothingType value)
public final FontSmoothingType getFontSmoothingType()
public final ObjectProperty<FontSmoothingType> fontSmoothingTypeProperty()
@Deprecated protected final void impl_geomChanged()
Node
This function will also invalidate the cached geom bounds, and then invoke localBoundsChanged() which will eventually end up invoking a chain of functions up the tree to ensure that each parent of this Node is notified that its bounds may have also changed.
This function should be treated as though it were final. It is not intended to be overridden by subclasses.
impl_geomChanged
in class Node
@Deprecated public final PathElement[] getImpl_selectionShape()
@Deprecated public final ReadOnlyObjectProperty<PathElement[]> impl_selectionShapeProperty()
@Deprecated public final void setImpl_selectionStart(int value)
@Deprecated public final int getImpl_selectionStart()
@Deprecated public final IntegerProperty impl_selectionStartProperty()
-1
to unset selection.@Deprecated public final void setImpl_selectionEnd(int value)
@Deprecated public final int getImpl_selectionEnd()
@Deprecated public final IntegerProperty impl_selectionEndProperty()
-1
to unset selection.@Deprecated public final ObjectProperty<Paint> impl_selectionFillProperty()
@Deprecated public final PathElement[] getImpl_caretShape()
@Deprecated public final ReadOnlyObjectProperty<PathElement[]> impl_caretShapeProperty()
@Deprecated public final void setImpl_caretPosition(int value)
@Deprecated public final int getImpl_caretPosition()
@Deprecated public final IntegerProperty impl_caretPositionProperty()
-1
to unset caret.@Deprecated public final void setImpl_caretBias(boolean value)
@Deprecated public final boolean isImpl_caretBias()
@Deprecated public final BooleanProperty impl_caretBiasProperty()
@Deprecated public final HitInfo impl_hitTestChar(Point2D point)
@Deprecated public final PathElement[] impl_getRangeShape(int start, int end)
@Deprecated public final PathElement[] impl_getUnderlineShape(int start, int end)
@Deprecated public final void impl_displaySoftwareKeyboard(boolean display)
@Deprecated protected final Bounds impl_computeLayoutBounds()
Node
impl_computeLayoutBounds
in class Node
@Deprecated public final BaseBounds impl_computeGeomBounds(BaseBounds bounds, BaseTransform tx)
Node
impl_computeGeomBounds
in class Shape
@Deprecated protected final boolean impl_computeContains(double localX, double localY)
impl_computeContains
in class Shape
@Deprecated public final Shape impl_configShape()
impl_configShape
in class Shape
public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
public List<CssMetaData<? extends Styleable,?>> getCssMetaData()
Node.getClassCssMetaData()
so that
a Node's CssMetaData can be accessed without the need for reflection.getCssMetaData
in interface Styleable
getCssMetaData
in class Shape
@Deprecated public final void impl_updatePeer()
Node
impl_updatePeer
in class Shape
public String toString()
Text
object.public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)
Node
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 super class implementation
must be called.
queryAccessibleAttribute
in class Node
attribute
- the requested attributeparameters
- optional list of parametersAccessibleAttribute
Copyright © 2020. All rights reserved.