How to change the Font in the entire Swing UI application

后端 未结 1 2042
余生分开走
余生分开走 2020-12-30 18:09

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

相关标签:
1条回答
  • 2020-12-30 18:34
    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 );  
                }  
            }  
        }  
    
    0 讨论(0)
提交回复
热议问题