如何在整个Swing UI应用程序中更改字体 [英] How to change the Font in the entire Swing UI application
本文介绍了如何在整个Swing UI应用程序中更改字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法可以达到同样的效果吗?
解决方案
public static void setGlobalFont(Font font){
Enumeration keys = UIManager.getDefaults()。keys();
while(keys.hasMoreElements()){
Object key = keys.nextElement();
Object value = UIManager.get(key);
if(value instanceof Font){
UIManager.put(key,font);
}
}
}
I have made a swing application. Now I want to change the Font of entire Swing Application , so that any component being added should follow that Font only. Is there any way to achieve the same ?
解决方案
public static void setGlobalFont( Font font ) {
Enumeration keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements() ) {
Object key = keys.nextElement();
Object value = UIManager.get( key );
if ( value instanceof Font ) {
UIManager.put( key, font );
}
}
}
这篇关于如何在整个Swing UI应用程序中更改字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文