Overview
The Text
class defines a node that displays a text.
Paragraphs are separated by '\n'
and the text is wrapped on
paragraph boundaries.
the code:
import javafx.scene.text.*;
Text {
x: 10
y: 50
font: Font { size: 20 }
content: "This is a test"
}
produces:
the code:
import javafx.scene.text.*;
Text {
font: Font { size: 20 }
content: "First row\nSecond row"
}
produces:
the code:
import javafx.scene.text.*;
Text {
font: Font { size: 20 }
wrappingWidth: 200
textAlignment: TextAlignment.JUSTIFY
content: "The quick brown fox jumps over the lazy dog"
}
produces:
Profile: common
Variable Summary
access | name | type | Can Read | Can Init | Can Write | Default Value | description |
---|---|---|---|---|---|---|---|
public | content | String | empty string |
Defines text string that is to be displayed. |
|||
public | font | Font | Font{} |
Defines the font of text. |
|||
public | overline | Boolean | false |
Defines if each line of text should have a line above it. |
|||
public | strikethrough | Boolean | false |
Defines if each line of text should have a line through it. |
|||
public | textAlignment | TextAlignment | TextAlignment.LEFT |
Defines horizontal text alignment in the bounding box. Defines horizontal text alignment in the bounding box. The width of the bounding box is defined by the widest row. Note: the last line in paragraph is not justified. TextAlignment.LEFTProfile: common |
|||
public | textOrigin | TextOrigin | TextOrigin.BASELINE |
Defines the origin of text coordinate system in local coordinates. Defines the origin of text coordinate system in local coordinates.
Note: in case multiple rows are rendered Profile: common |
|||
public | underline | Boolean | false |
Defines if each line of text should have a line below it. |
|||
public | wrappingWidth | Number | 0 |
Defines width constrain for the text in pixels. Defines width constrain for the text in pixels.
If the value is Profile: common |
|||
public | x | Number | 0 |
Defines the X coordinate of text origin. |
|||
public | y | Number | 0 |
Defines the Y coordinate of text origin. |
Inherited Variables
javafx.scene.shape.Shape
access | name | type | Can Read | Can Init | Can Write | Default Value | description |
---|---|---|---|---|---|---|---|
public | fill | Paint |
Defines parameters to fill the interior of an Defines parameters to fill the interior of an Profile: common |
||||
public | smooth | Boolean | true |
Defines whether antialiasing hints are used or not for this Defines whether antialiasing hints are used or not for this Profile: common |
|||
public | stroke | Paint |
Defines parameters of a stroke that is drawn around the outline of
a Defines parameters of a stroke that is drawn around the outline of
a Profile: common |
||||
public | strokeDashArray | Number[] | [1.0] |
Defines the array representing the lengths of the dash segments. Defines the array representing the lengths of the dash segments.
Alternate entries in the array represent the user space lengths
of the opaque and transparent segments of the dashes.
As the pen moves along the outline of the Profile: common |
|||
public | strokeDashOffset | Number | 0 |
Defines a distance specified in user coordinates that represents an offset into the dashing pattern. Defines a distance specified in user coordinates that represents an offset into the dashing pattern. In other words, the dash phase defines the point in the dashing pattern that will correspond to the beginning of the stroke. 0Profile: common |
|||
public | strokeLineCap | StrokeLineCap | SQUARE |
The end cap style of this |
|||
public | strokeLineJoin | StrokeLineJoin | MITER |
Defines the decoration applied where path segments meet. Defines the decoration applied where path segments meet.
The value must have one of the following values:
Profile: common |
|||
public | strokeMiterLimit | Number | 10 |
Defines the limit for the |
|||
public | strokeWidth | Number | 1.0 |
Defines a square pen line width. Defines a square pen line width. A value of 0.0 specifies a hairline stroke. 1.0Profile: common |
javafx.scene.Node
access | name | type | Can Read | Can Init | Can Write | Default Value | description |
---|---|---|---|---|---|---|---|
public | blocksMouse | Boolean | false |
If If Profile: common conditional mouse |
|||
public-read | boundsInLocal | Rectangle2D |
The rectangular bounds of this The rectangular bounds of this
Note that this method does not take the node's visibility into account;
the test is based on the geometry of this This variable will always be a non-null value. Note that boundsInLocal is automatically recomputed whenever the geometry of a node changes. For this reason, it is an error to bind any of these values in a node to an expression that depends upon this variable. For example, you should not bind the "x" or "y" variables of a shape to boundsInLocal for the purpose of positioning the node. Profile: common |
||||
public-read | boundsInParent | Rectangle2D |
The rectangular bounds of this The rectangular bounds of this
The resulting bounds will be conceptually in the coordinate space of the
Note that this method does not take the node's visibility into account;
the test is based on the geometry of this This variable will always be a non-null value. Note that boundsInParent is automatically recomputed whenever the geometry of a node changes, or when any of the following change: the transforms sequence, the translateX, translateY, scaleX, scaleY, or rotate variable. For this reason, it is an error to bind any of these values in a node to an expression that depends upon this variable. For example, you should not bind the "x", "y", translateX, or translateY variables of a shape to boundsInParent for the purpose of positioning the node. Profile: common |
||||
public-read | boundsInScene | Rectangle2D |
The rectangular bounds of this The rectangular bounds of this
Note that this method does not take the node's visibility into account;
the test is based on the geometry of this This variable will always be a non-null value. Note that boundsInScene is automatically recomputed whenever any transform in any ancestor group node changes, or when the geometry of a node changes, or when any of the following change: the transforms sequence, the translateX, translateY, scaleX, scaleY, or rotate variable. For this reason, it is an error to bind any of these values in a node to an expression that depends upon this variable. For example, you should not bind the "x", "y", translateX, or translateY variables of a shape to boundsInScene for the purpose of positioning the node. Profile: common |
||||
public | cache | Boolean | false |
A performance hint to the system to indicate that this A performance hint to the system to indicate that this Profile: common |
|||
public | clip | Node | null |
Specifies a Specifies a For example, you can use an javafx.scene.image.ImageView Node as a mask to represent the Clip. Or you could use one of the geometric shape Nodes such as javafx.scene.shape.Rectangle or javafx.scene.shape.Circle. Or you could use a javafx.scene.text.Text node to represent the Clip. nullProfile: common conditional clip |
|||
public | cursor | Cursor | null |
Defines the mouse cursor for this Defines the mouse cursor for this Profile: common conditional cursor |
|||
public | disable | Boolean | false |
Sets the individual disabled state of this Sets the individual disabled state of this Profile: common |
|||
public-read | disabled | Boolean | false |
Indicates whether or not this Indicates whether or not this
A disabled Profile: common |
|||
public | effect | Effect | null |
Specifies an effect to apply to this |
|||
public | focusable | Boolean | true |
Specifies whether this Specifies whether this Profile: common |
|||
public-read protected | focused | Boolean | subclass | subclass | subclass | false |
Indicates whether this Indicates whether this Profile: common |
public-read protected | hover | Boolean | subclass | subclass | subclass | false |
Whether or not this Whether or not this Profile: common |
public | id | String | empty string |
The id of this The id of this Profile: common |
|||
public-init | layoutBounds | Rectangle2D |
The rectangular bounds that should be used in calculations for both manual
and automatic layout of this The rectangular bounds that should be used in calculations for both manual
and automatic layout of this
Note that the translateX and translateY variables are not
included in the layoutBounds by default. This is important because
layout code must first determine the current size and location of the
Note that the default layoutBounds is automatically recomputed whenever the geometry of a node changes, or when the transforms sequence changes. For this reason, it is an error to bind any of these values in a node to an expression that depends upon this variable. For example, you should not bind the "x" or "y" variables of a shape to layoutBounds for the purpose of positioning the node. Profile: common |
||||
public | onKeyPressed | function(:KeyEvent):Void |
Defines a function to be called when this |
||||
public | onKeyReleased | function(:KeyEvent):Void |
Defines a function to be called when this |
||||
public | onKeyTyped | function(:KeyEvent):Void |
Defines a function to be called when this Defines a function to be called when this Profile: common conditional keyboard |
||||
public | onMouseClicked | function(:MouseEvent):Void |
Defines a function to be called when a mouse button has been clicked
(pressed and released) on this |
||||
public | onMouseDragged | function(:MouseEvent):Void |
Defines a function to be called when a mouse button is pressed
on this |
||||
public | onMouseEntered | function(:MouseEvent):Void |
Defines a function to be called when the mouse enters this |
||||
public | onMouseExited | function(:MouseEvent):Void |
Defines a function to be called when the mouse exits this |
||||
public | onMouseMoved | function(:MouseEvent):Void |
Defines a function to be called when mouse cursor moves within
this |
||||
public | onMousePressed | function(:MouseEvent):Void |
Defines a function to be called when a mouse button
has been pressed on this |
||||
public | onMouseReleased | function(:MouseEvent):Void |
Defines a function to be called when a mouse button
has been released on this |
||||
public | onMouseWheelMoved | function(:MouseEvent):Void |
Defines a function to be called when the mouse scroll wheel has moved. |
||||
public | opacity | Number | 1.0 |
Specifies how opaque (that is, solid) the Specifies how opaque (that is, solid) the A visible node with any opacity setting still receives mouse events and can receive keyboard focus. For example, if you want to have a large invisible rectangle overlay all Nodes in the scene graph in order to intercept mouse events but not be visible to the user, you could create a large Rectangle that had an opacity of 0%. Opacity is specified as a value between 0 and 1. Values less than 0 or greater than one are clipped to 0 and 1 respectively. On some platforms ImageView might not support opacity variable. 1.0Profile: common |
|||
public-read package | parent | Node | null |
The parent of this The parent of this Profile: common |
|||
public-read protected | pressed | Boolean | subclass | subclass | subclass | false |
Whether or not the Whether or not the Profile: common |
public | rotate | Number | 0.0 |
Defines the angle of rotation about the Defines the angle of rotation about the This rotation factor is not included in layoutBounds by default, which makes it ideal for rotating the entire node after all effects and transforms have been taken into account. The pivot point about which the rotation occurs is the center of the rectangular bounds formed by taking boundsInLocal and applying all the transforms in the transforms[] sequence.
Note that the center of this Profile: common |
|||
public | scaleX | Number | 1.0 |
Defines the factor by which coordinates are scaled about the center of the
object along the X axis of this Defines the factor by which coordinates are scaled about the center of the
object along the X axis of this This scale factor is not included in layoutBounds by default, which makes it ideal for scaling the entire node after all effects and transforms have been taken into account. The pivot point about which the scale occurs is the center of the rectangular bounds formed by taking boundsInLocal and applying all the transforms in the transforms[] sequence. 1.0Profile: common |
|||
public | scaleY | Number | 1.0 |
Defines the factor by which coordinates are scaled about the center of the
object along the Y axis of this Defines the factor by which coordinates are scaled about the center of the
object along the Y axis of this This scale factor is not included in layoutBounds by default, which makes it ideal for scaling the entire node after all effects and transforms have been taken into account. The pivot point about which the scale occurs is the center of the rectangular bounds formed by taking boundsInLocal and applying all the transforms in the transforms[] sequence. 1.0Profile: common |
|||
public-read package | scene | Scene | null |
The Scene that this The Scene that this Profile: common |
|||
public | style | String | empty string |
A string representation of the CSS style associated with this specific Node. A string representation of the CSS style associated with this specific Node. This is exactly analogous to the "style" attribute on an HTML element, but uses the syntax defined in JavaFX CSS. empty stringProfile: desktop |
|||
public | styleClass | String | empty string |
A String identifier which can be used to logically group Nodes, specifically for an external style engine. A String identifier which can be used to logically group Nodes, specifically for an external style engine. This variable is exactly analogous to the styleClass attribute on an HTML element. empty stringProfile: common |
|||
public | transforms | Transform[] | empty |
Defines the sequence of javafx.scene.transform.Transform objects
to be applied to this Defines the sequence of javafx.scene.transform.Transform objects
to be applied to this By default, layoutBounds is defined as the local bounds with all the transforms in this sequence applied. emptyProfile: common |
|||
public | translateX | Number | 0 |
Defines the X coordinate of the translation that is added to the
transformed coordinates of this Defines the X coordinate of the translation that is added to the
transformed coordinates of this For example, if This translation factor is not included in layoutBounds by default, which makes it ideal for moving the entire node around after all effects and transforms are taken into account. 0Profile: common |
|||
public | translateY | Number | 0 |
Defines the Y coordinate of the translation that is added to the
transformed coordinates of this Defines the Y coordinate of the translation that is added to the
transformed coordinates of this For example, if This translation factor is not included in layoutBounds by default, which makes it ideal for moving the entire node around after all effects and transforms are taken into account. 0Profile: common |
|||
public | visible | Boolean | true |
Specifies whether this Specifies whether this Profile: common |
Function Summary
- protected impl_createSGNode() : com.sun.scenario.scenegraph.SGNode
- public impl_hitTestChar(point: Point2D) : Integer
Inherited Functions
javafx.scene.shape.Shape
- public impl_getSGAbstractShape() : com.sun.scenario.scenegraph.SGAbstractShape
- public intersects(localX: Number, localY: Number, localWidth: Number, localHeight: Number) : Boolean
- public intersects(localRect: Rectangle2D) : Boolean
- public ofTheWay(endVal: java.lang.Object, t: Number) : java.lang.Object
javafx.scene.Node
- public contains(localX: Number, localY: Number) : Boolean
-
Returns
true
if the given point (specified in the local coordinate space of thisNode
) is contained within the shape of thisNode
.Returns
true
if the given point (specified in the local coordinate space of thisNode
) is contained within the shape of thisNode
. Note that this method does not take visibility into account; the test is based on the geometry of thisNode
only. The default behavior of this function is simply to check if the given coordinates are contained in the local bounds.-
Parameters
- localX
- localY
-
Returns
- Boolean
Profile: common
- public contains(localPoint: Point2D) : Boolean
-
Returns
true
if the given point (specified in the local coordinate space of thisNode
) is contained within the shape of thisNode
.Returns
true
if the given point (specified in the local coordinate space of thisNode
) is contained within the shape of thisNode
. Note that this method does not take visibility into account; the test is based on the geometry of thisNode
only. The default behavior of this function is simply to check if the given coordinates are contained in the local bounds.-
Parameters
- localPoint
-
Returns
- Boolean
Profile: common
- protected abstract impl_createSGNode() : com.sun.scenario.scenegraph.SGNode
- public impl_getFXNode() : com.sun.scenario.scenegraph.fx.FXNode
- public impl_getPivotX() : Number
- public impl_getPivotY() : Number
- protected impl_getSGNode() : com.sun.scenario.scenegraph.SGNode
- protected impl_requestLayout() : Void
- public impl_updateFXNodeTransform() : Void
- public intersects(localX: Number, localY: Number, localWidth: Number, localHeight: Number) : Boolean
-
Returns
true
if the given rectangle (specified in the local coordinate space of thisNode
) intersects the shape of thisNode
.Returns
true
if the given rectangle (specified in the local coordinate space of thisNode
) intersects the shape of thisNode
. Note that this method does not take visibility into account; the test is based on the geometry of thisNode
only. The default behavior of this function is simply to check if the given coordinates intersect with the local bounds.-
Parameters
- localX
- localY
- localWidth
- localHeight
-
Returns
- Boolean
Profile: common
- public intersects(localRect: Rectangle2D) : Boolean
-
Returns
true
if the given rectangle (specified in the local coordinate space of thisNode
) intersects the shape of thisNode
.Returns
true
if the given rectangle (specified in the local coordinate space of thisNode
) intersects the shape of thisNode
. Note that this method does not take visibility into account; the test is based on the geometry of thisNode
only. The default behavior of this function is simply to check if the given coordinates intersect with the local bounds.-
Parameters
- localRect
-
Returns
- Boolean
Profile: common
- public localToParent(localX: Number, localY: Number) : Point2D
- public localToParent(localPoint: Point2D) : Point2D
- public localToScene(localX: Number, localY: Number) : Point2D
-
Transforms a point from the local coordinate space of this
Node
into the coordinate space of its javafx.scene.Scene.Transforms a point from the local coordinate space of this
Node
into the coordinate space of its javafx.scene.Scene.-
Parameters
- localX
- localY
-
Returns
- Point2D
Profile: common
- public localToScene(localPoint: Point2D) : Point2D
-
Transforms a point from the local coordinate space of this
Node
into the coordinate space of its javafx.scene.Scene.Transforms a point from the local coordinate space of this
Node
into the coordinate space of its javafx.scene.Scene.-
Parameters
- localPoint
-
Returns
- Point2D
Profile: common
- public lookup(id: java.lang.String) : Node
-
Finds this
Node
, or the first subnode, with the given id.Finds this
Node
, or the first subnode, with the given id. If multiple subnodes have the same id, this function returns one of them. Which node it returns in that case is unspecified.-
Parameters
- id
- The id of the node to find
-
Returns
- Node
-
The first node, starting from this
Node
, which has an id ofid
.
Profile: common
- public parentToLocal(parentX: Number, parentY: Number) : Point2D
- public parentToLocal(parentPoint: Point2D) : Point2D
- public requestFocus() : Void
-
Requests that this
Node
get the input focus, and that thisNode
's top-level ancestor become the focused Window.Requests that this
Node
get the input focus, and that thisNode
's top-level ancestor become the focused Window. If this node is not part of a scene graph rooted in a stage that is visible and can accept input focus, then calls to request focus will not cause thisNode
to become focused.Profile: common
- public sceneToLocal(sceneX: Number, sceneY: Number) : Point2D
- public sceneToLocal(scenePoint: Point2D) : Point2D
-
Transforms a point from the coordinate space of the javafx.scene.Scene into the local coordinate space of this
Node
.Transforms a point from the coordinate space of the javafx.scene.Scene into the local coordinate space of this
Node
.-
Parameters
- scenePoint
-
Returns
- Point2D
Profile: common
- public toBack() : Void
-
Moves this
Node
to the back of its sibling nodes in terms of z-order.Moves this
Node
to the back of its sibling nodes in terms of z-order. This is accomplished by moving thisNode
to the first position in its parent'scontent
sequence. This function has no effect if thisNode
is not part of a group.Profile: common
- public toFront() : Void
-
Moves this (@code Node} to the front of its sibling nodes in terms of z-order.
Moves this (@code Node} to the front of its sibling nodes in terms of z-order. This is accomplished by moving this
Node
to the last position in its parent'scontent
sequence. This function has no effect if thisNode
is not part of a group.Profile: common
- public toString() : java.lang.String
javafx.animation.Interpolatable
- public abstract ofTheWay(endVal: java.lang.Object, t: Number) : java.lang.Object
-
The function calcuates an interpolated value along the
t
between0.0
and1.0
.The function calcuates an interpolated value along the
t
between0.0
and1.0
. Whent
= 1.0,endVal
is returned.-
Parameters
- endVal
- target value
- t
-
fraction between
0.0
and1.0
-
Returns
- Object
- interpolated value
Profile: common