Java Swing JLabel, HTML and custom fonts

前端 未结 2 1275
旧巷少年郎
旧巷少年郎 2021-02-10 02:46

In our Java Swing application, we\'re loading a custom font and adding it to a JLabel:

try {
  this.font = Font.createFont(Font.TRUETYPE_FONT, new F         


        
2条回答
  •  执笔经年
    2021-02-10 03:13

    To use some font:

    ...
    

    The Font you created has to be registered first in the singleton GraphicsEnvironment to be accessible to all:

    GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    genv.registerFont(font);
    

提交回复
热议问题