简体   繁体   中英

How to change the Font in the entire Swing UI application

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 );  
            }  
        }  
    }  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM