JLabel html text ignores setFont

前端 未结 2 986
闹比i
闹比i 2021-01-04 19:00

I\'ve just started porting my Swing app from OS X to Windows and things are painful with JLabels.

I\'ve noticed that the font specified to setFont

2条回答
  •  没有蜡笔的小新
    2021-01-04 19:39

    registerFont()

    I found this little gem while Googling about if I could copy a .ttf into the JRE at runtime. It does exactly what it's supposed to. If you use Font.createFont to load a font at runtime, just do:

    GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(myCreatedFont)

    to register it with the JRE.

    This allows the font to show up in HTML'd text as well as plaintext on Windows!

提交回复
热议问题