Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the Font in the entire Swing UI application

Tags:

java

fonts

swing

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 ?

like image 336
Abhishek Choudhary Avatar asked Dec 28 '22 19:12

Abhishek Choudhary


1 Answers

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 );  
            }  
        }  
    }  
like image 148
Saurabh Gokhale Avatar answered Feb 07 '23 11:02

Saurabh Gokhale