簡體   English   中英

使用 Netbeans IDE,如何更改 JLabel 的字體

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

我正在使用 Netbeans IDE 11.2,我想知道是否有什么我可以做的事情來更改股票 Windows 字體中的 Jlabel 字體(我已經安裝了幾種字體)。

無論使用哪種 IDE,您都可以像這樣在代碼視圖中執行此操作。

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

您可以繼承 JLabel 並在修改后的組件的構造函數中更改字體。 下面的鏈接解釋了如何在 NetBeans 調色板中包含自定義組件(請注意,它已經很舊了):

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM