2017-06-18 31 views

回答

0

下面的代碼應該做的伎倆(改變你的JLabel的字體):

JLabel text1 = new JLabel(); 
test1.setFont(new Font("FontName", Font.ITALIC, 100)); 
text1.setText("Your text here"); 

而且,如果字體不是您的系統上,或者您需要添加它,看看createFont()方法

http://docs.oracle.com/javase/7/docs/api/java/awt/Font.html#method_summary

createFont(int fontFormat, File fontFile) 
Returns a new Font using the specified font type and the specified font file. 

試試這個,並告訴我們它是否工作!

+0

這個問題可能是重複的,我敢肯定OP想使用自定義字體。你不提供這樣的代碼示例。 –

+0

我不明白第二部分。我不知道如何把確切的目錄放在這裏。我在C:\ Windows \ Fonts中得到了這個,字體名稱是DIN 1451 Std Engschrift.otf。如何將其轉移到我的GUI框架中? –