如何将html放入Java的JLabel中?

2022-09-03 04:30:47

如何在Java的JLabel中使用html标签?


答案 1

要将 html 放入 ,您会使其看起来像这样JLabel

 JLabel label = new JLabel("<html><yourTagHere><yourOtherTagHere>this is your text</yourOtherTagHere></yourTagHere></html>");

答案 2

这将解决问题:

 String labelText ="<html><FONT COLOR=RED>Red</FONT> and <FONT COLOR=BLUE>Blue</FONT> Text</html>";
 JLabel coloredLabel =new JLabel(labelText);