简体   繁体   中英

Using Netbeans IDE, how do you change the font of a JLabel

我正在使用 Netbeans IDE 11.2,我想知道是否有什么我可以做的事情来更改股票 Windows 字体中的 Jlabel 字体(我已经安装了几种字体)。

Regardless of IDE you can do it in your code view like this.

JLabel label = new JLabel("First Name");
label.setFont(new Font("Courier New", Font.ITALIC, 12));
label.setForeground(Color.GRAY);

You could subclass JLabel and change the font in the constructor of your modified component. The link below explains how to include custom components in the NetBeans palette (beware, it's quite old):

https://joanpaon.wordpress.com/2013/07/12/how-to-install-a-custom-swing-component-in-netbeans-palette/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM