Overview
JLabel extends JavaFX Label with:- Integrated JIcon support
- Icon color customization
- Method chaining for styles
- Multiline text support
Constructors
Creates an empty label.
Creates a label with the specified text.
Creates a label with only an icon.
Creates a label with both text and icon.
Basic Usage
Icon Support
Sets or removes the label’s icon.Returns the label instance for method chaining.
Sets the color of the icon graphic.Returns the label instance for method chaining.
Styling
Adds one or more CSS style classes to the label.Returns the label instance for method chaining.
Alias for withStyle(). Adds CSS style classes to the label.Returns the label instance for method chaining.
Multiline
Enables or disables text wrapping.Returns the label instance for method chaining.
Examples
Label with Icon and Color
Styled Section Header
Icon-Only Label
Multiline Label
Inherits From
JLabel extendsjavafx.scene.control.Label, so all standard JavaFX Label methods are available:
setText(String)- Set label textgetText()- Get label textsetTextAlignment(TextAlignment)- Set text alignmentsetContentDisplay(ContentDisplay)- Control icon/text positioningsetGraphic(Node)- Set custom graphic (note: setIcon() is preferred for JIcon)