Labelled
The base class for many Nodes which display a single line of text (and an optional graphic
). Label is the obvious subclass, but there are many others, including Button.
Anatomy
Example 1. When contentDisplay = LEFT, alignment = BOTTOM_LEFT :
◁╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌width╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌▷
◁╌╌╌╌╌╌╌╌╌╌╌╌╌prefWidth╌╌╌╌╌╌╌╌╌╌╌▷
◁╌╌╌╌labelPadding.left╴
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓} borderSize.top
┃ ┃
┃ ┌╌╌╌╌╌╌╌╌╌╌╌┐ s ┃
┃ ┌╌╌╌╌╌╌╌┐ ┆ ┆ p ┃ } labelPadding.top
┃ ┆ ┆ ┆ text ┆ a ┃
┃ ┆graphic┆ ┆ ┆ c ┃ } labelPadding.bottom
┃ └╌╌╌╌╌╌╌┘ └╌╌╌╌╌╌╌╌╌╌╌┘ e ┃
┃ ┃ } padding.bottom
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ } borderSize.bottom
◁╌╌╌╌padding.left╴
◁╌╌╌╌╌graphicTextGap╴
If the width allocated to the Labelled == prefWidth, then there will be no space on the right (apart from padding.right) and the horizontal part of alignment will make no difference.
Example 2. When contentDisplay = TOP, alignment = TOP_CENTER : ┏━━━━━━━━━━━━━━━━━━━━┓ } borderSize.top ┃ ┃ ╷ padding.top ┃ ┌╌╌╌╌╌╌╌┐ ┃ ╵ ┃ ┆ ┆ ┃ ┃ ┆graphic┆ ┃ ┃ └╌╌╌╌╌╌╌┘ ┃ ╷ ┃ ┃ ┆ graphicTextGap ┃ ┌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┐ ┃ ╵ ┃ ┆ ┆ ┃ } labelPadding.top ┃ ┆ text ┆ ┃ ┃ ┆ ┆ ┃ } labelPadding.bottom ┃ └╌╌╌╌╌╌╌╌╌╌╌╌╌╌┘ ┃ ┃ ┃ } padding.bottom ┃ empty space ┃ ┃ ┃ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━┛ } borderSize.bottom ◁╌╌╌╌▷ labelPadding.left ◁╌▷ padding.left If the height allocated to the Labelled == prefHeight, then there will be no space at the bottom (apart from padding.bottom) and the vertical part of alignment will make no difference.
The thick lines are the visible border (see super-class Region).
The dashed inner lines are not drawn.
The graphic has no padding of its own.
The graphic which can be any Node.
contentDisplay determines where the graphic is compared to the text (the defaults is ContentDisplay.LEFT).
When contentDisplay is TOP
or BOTTOM
, graphicTextGap is the Y distance, otherwise it is the X distance.
Theme DSL
("label" or "button" or "toggleButton" ... ) {
alignment( value : Pos )
contentDisplay( value : ContentDisplay )
font( value : Font )
font( size : Int, style : FontStyle, family : String... )
font( size : Int, family : String... )
graphicTextGap( value : Number )
labelPadding( value : Edges )
labelPadding( size : Number )
labelPadding( topBottom : Number, leftRight : Number )
labelPadding( top : Number, right : Number, bottom : Number, left : Number )
textColor( value : Color )
textColor( value : String )
}
Labelled inherits all the features of Region.
Inheritors
Properties
The base class Node has no children, so this is an empty list.
Functions
Converts em
units to LogicalPixels.
Each subclass of node can determine the minimum width it requires. This can be overridden on an ad-hoc basis using overrideMinHeight. The default implementation returns 0.
Each subclass of node can determine the minimum width it requires. This can be overridden on an ad-hoc basis using overrideMinWidth. The default implementation returns 0.
Each subclass of node can determine its preferred height. As most nodes are composed of smaller nodes, this is typically calculated using evalPrefWidth of the child nodes, with extra added for spacing, padding and borders.
Each subclass of node can determine its preferred width. As most nodes are composed of smaller nodes, this is typically calculated using evalPrefWidth of the child nodes, with extra added for spacing, padding and borders.