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 ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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 );
}
}
}