2
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 snippet of code prints the 'b' on the screen too.
2
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 snippet of code prints the 'b' on the screen too.
3
You need to wrap the whole text between the tags <html>
and </html>
:
label.setText("<html>apenas esta parte em <b>negrito</b></html>");
However, I suggest using alternative components, which allow you to do this without soiling the code with these individual html snippets: JTextPane
or JEditorPane
. In this answer there is an example of using one of these components and of what they are able to do.
Browser other questions tagged java swing formatting jlabel
You are not signed in. Login or sign up in order to post.
Thank you, I had no idea it would be so simple
– P. Dominges
@P.Dominges yes, but it is good to use only for sporadic cases, since these excerpts make it difficult to read and maintain the code.
– user28595