I consider the default look and feel of Java plainly horrible, it resemble shiny effects of the 90’s. Well, it was created around then, and it hasn’t evolved since:

parameters

Although there is alternative themes, they all have their problems. The ones included in Java (such as Nimbus) feel equally old, inherit the Look and feel of the OS carries a lot of problems with compatibility, and using external libraries is a hassle in terms of packaging and licensing.

I have learnt a couple of things of design (please ignore my website design) in the last few years, and I decided that there are three basic problems with the default Java Look and Feel.

  1. The bold titles occupy too much space
  2. The shiny buttons are cheesy
  3. The buttons are bulky

It is a combination of cheesyness and bulkyness. So, let’s quickly improve this. First, we need a method to change the font of all the interface components.

private static void setUIFont (javax.swing.plaf.FontUIResource f){
    Enumeration<object width="300" height="150"> keys = UIManager.getDefaults().keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = UIManager.get (key);
        if (value != null && value instanceof javax.swing.plaf.FontUIResource)
            UIManager.put (key, f);
    }
} 

Once that is done, we will change (1) the font of the components, (2) remove the metal shiny color for a plain gray, and (3) add a modest line border:

    setUIFont (new javax.swing.plaf.FontUIResource("Sans Serif",Font.PLAIN,12));
    UIManager.put("Button.background",  Color.decode("#eeeeee"));
    UIManager.put("ToggleButton.background",  Color.decode("#eeeeee"));
    UIManager.put("Button.border", new CompoundBorder(new LineBorder(new Color(200, 200, 200)), new EmptyBorder(2, 2, 2, 2)));
    UIManager.put("ToggleButton.border", new CompoundBorder(new LineBorder(new Color(200, 200, 200)), new EmptyBorder(2, 2, 2, 2)));
    // call on the JFrame

The previous code should be added just before you call the JFrame. Here is the result:

parametersafter

It is not perfect, but I would say that now it is decent. Here is another couple of images of another interface of my Cultural Simulator:

Before:

before

After:

after

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

required