Importing Font to GUI

后端 未结 3 1218
[愿得一人]
[愿得一人] 2021-01-24 07:54

I am trying to change the font for my GUI besides the basic 5 that swing seems to come with. How to import fonts and actually use them in my code?

3条回答
  •  鱼传尺愫
    2021-01-24 08:46

    You can try with this:

    Font font = Font.createFont(Font.TRUETYPE_FONT, fontStream);
    

    Next,

    GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(font);
    

    And,

    new Font("nameOfFont", Font.BOLD, 13)
    

提交回复
热议问题