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