HTML in JLabel not showing

前端 未结 2 1635
执念已碎
执念已碎 2020-12-21 05:40
JLabel label = new JLabel(\"Hello world\");

shows nothing.

If I get rid of the tags, it

2条回答
  •  感动是毒
    2020-12-21 06:07

    If you want to mix fonts or colors within the text, or if you want formatting such as multiple lines, you can use HTML. HTML formatting can be used in all Swing buttons, menu items, labels, tool tips, and tabbed panes, as well as in components such as trees and tables that use labels to render text.

    Refer this example HtmlDemo.java


    In your example

     JLabel label = new JLabel("Hello world"); 
    

    you are not applying any formating like bold or italic etc..

    also is not required.

    Hope it helps.

提交回复
热议问题