Here is a simple way that allows you to specify a font for the entire tree of components in any container (or just a simple component, it does not matter):
public static void changeFont ( Component component, Font font ) { component.setFont ( font ); if ( component instanceof Container ) { for ( Component child : ( ( Container ) component ).getComponents () ) { changeFont ( child, font ); } } }
Just pass your panel and special font to this method, and you will also receive all refactoring for children.
Mikle garin
source share