Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8101503

Allow formatted text on a label

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P3 P3
    • 8
    • None
    • javafx
    • None

      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>.");

            leifs Leif Samuelsson (Inactive)
            risaksen Randahl Isaksen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: