JDK-8101503 : Allow formatted text on a label
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: controls
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • Submitted: 2011-08-30
  • Updated: 2015-06-16
  • Resolved: 2012-08-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Resolved
Related Reports
Duplicate :  
Relates :  
Description
It is sometimes necessary to style individual words or characters of a label. Examples include

1. Underlining a letter of a word which communicates a keyboard shortcut
2. Emphasizing something as being an entity as in this message: "The customer *Stella Johnsson* is not a member of the group *International*.

In swing you could make JLabel do this by setting its contents to "This is <b>in bold letters</b>". As I recall, both <b>, <i> and <u> was supported.

I do not think Swing's solution to this was particularly flexible nor elegant. I would prefer the <span> tag to be supported, allowing me to decouple the styling into a .css file:

myLabel.setText("This is an <span class="employeeId">employee id</span>.");