Is there any way to leave only a portion of the bold text of a JLabel?
For example:
label.setText("apenas esta parte em <b>negrito</b>");
But this code snippet prints the 'b' on the screen too.
Is there any way to leave only a portion of the bold text of a JLabel?
For example:
label.setText("apenas esta parte em <b>negrito</b>");
But this code snippet prints the 'b' on the screen too.
You need to wrap the whole text between the <html>
and </html>
tags:
label.setText("<html>apenas esta parte em <b>negrito</b></html>");
However, I suggest using alternate components, which allow you to do this without messing up code with these html's strings: JTextPane
or JEditorPane
. In this answer there is an example of using one of these components and what they are capable of to do.