Options Window Color Analysis

So you're happily using JTattoo in your NetBeans Platform application. However, when you use the darker variations, such as "com.jtattoo.plaf.graphite.GraphiteLookAndFeel", you run into a problem. Though all the colors change as you'd expect... there's still the white background at the top of the Options window, as you can see below. 

That may seem like a small and insignificant problem. However, in the real world, Java and the NetBeans Platform are to be found in air traffic management and air traffic control systems, where the possibility of switching between a "day view" and a "night view", with all the related color updates, is not a "nice to have", but a "must".

So, the pesky white bar at the top of the Options window is a real problem in these real scenarios. A glaring white background is the very last thing you want in the Options window when the traffic controller has switched to "night view".

How to fix it? First, run the application from NetBeans IDE in Debug mode, open the Options window, and then click the orange camera button in the toolbar. Now a snapshot is made of the Options window and rendered in NetBeans IDE, where you can click on anything in the snapshot and see its related properties, such as the name of the panel where that white background is defined:

Then dig into the source code and find that panel. You now find that "Tree.background" is the relevant UIManager color for the white background in the Options window:

private static Color getTabPanelBackground() {
    if( isMetal || isNimbus ) {
        Color res = UIManager.getColor( "Tree.background" ); //NOI18N
        if( null == res )
            res = Color.white;
        return new Color( res.getRGB() );
    }
    return Color.white;
}

Switch into your @OnStart annotated Runnable and use "Tree.background" as shown below:

@OnStart
public class Startable implements Runnable {
    @Override
    public void run() {
        try {
            UIManager.setLookAndFeel("com.jtattoo.plaf.graphite.GraphiteLookAndFeel");
            UIManager.put("Tree.background", Color.LIGHT_GRAY);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Startable.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(Startable.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Startable.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(Startable.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

And here's the Options window again, gone is the white background at the top:

Don't like the light gray color I set above? Fine, change it to another color. The point is that you now have control over that color and you also know how to figure out similar problems next time.

Comments:

Geertjan,

I am an innovation consultant from Bangalore India. I will be conducting a workshop for IC5s at Oracle Bangalore tomorrow. One of the modules will be to write a position blog where each participant will write and upload a blog on Oracle Intranet. Hence, I was going through some of the blogs at Oracle site. You seem to be writing a blog *every day*!! How do you manage that? I will be meeting engineers tomorrow who will complain that they don't get any time to do stuff like writing a blog :-) What is your magic wand?

cheers,
Vinay

Posted by guest on January 21, 2014 at 01:44 AM PST #

Well, I get questions from users every day, so I tend to need to answer them every day and sharing answers with the world saves time because next time someone asks the same question, I can point them to my blog. Also, my blog is primarily a way for me to have a repository of solutions, i.e., I often forget something I learned 5 years ago, but now I have a place to go to to find my old answers. Drop me a line at geertjan.wielenga@oracle.com and we can talk more about it, would be happy to help you with your workshops and participate in any way you like. Blogging makes work more fun, too.

Posted by Geertjan on January 21, 2014 at 03:16 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today