Search code examples
javamacosswinglook-and-feelquaqua

How can I manage swing UI default font sizes without quaqua?


We are trying to get quaqua out of our application. We had been using a call to quaqua to set the font size to be smaller with a call like this:

System.setProperty("Quaqua.sizeStyle", "small");

Is there an easy to do the same sort of thing without using quaqua? Or does anyone know another good look and feel for OS X?


Solution

  • I also had an almost similar challenge, setting all font to a specific font. The code below will change the font size for all *.font properties in UIManager to a particular size

    private static void setFontSize() {
        int fontSize = 12;
        Hashtable defaults = UIManager.getDefaults();
        Enumeration keys = defaults.keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
    
            if ((key instanceof String) && (((String) key).endsWith(".font"))) {
                FontUIResource font = (FontUIResource) UIManager.get(key);
                defaults.put (key, new FontUIResource(font.getFontName(), font.getStyle(), fontSize));
            }
        }
     }