Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 763
Mike2012 Avatar asked Feb 01 '26 13:02

Mike2012


1 Answers

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));
        }
    }
 }
like image 96
n002213f Avatar answered Feb 04 '26 07:02

n002213f



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!