Skip to main content

About Plastic Look and Feel

Posted by gfx on July 24, 2005 at 12:12 AM PDT

The Plastic look and feel family is very well known and widely used among Java community. That said I am often disappointed to see some programmers plug it into their UI without taking a look at the available options. Let's take a look at a sample, rather bad looking Swing application:


"Yiech!" And you're right. One way to fix this UI is to change the look and feel. Now, it has many other issues, like colors and icons, but we won't bother about this today. I know Plastic looks great and I also know a lot of people like. Best of all it's free and open source, so why not use it? Here we go:

PlasticLookAndFeel laf = new PlasticXPLookAndFeel();
PlasticLookAndFeel.setMyCurrentTheme(new ExperienceBlue());

Note I chose a theme for the look and feel because, after all, I really do care about the result:


Ah much better, isn't it? Many programmers would just stop here and go back to more interesting stuff. Yet we can go a bit further with three extra lines of code:


As a result, Plastic applies a different style to both the menu bar and the tool bar, giving them a nice, modern rounded look:


I also use Swing's JToolBar.isRollover property to hide buttons borders. Even if the result is better looking, both bars show unecessary borders which clutter the screen, mainly on the left and right of the frame. I'll let you get rid of them as an exercise :) And we can go even further by adding drop shadows to popup menus:


Those menus integrate nicely with Windows XP:


Finally you might not like tabs look. The last feature of Plastic I'm about to use let you give tabs an Eclipse look:


The only problem is that selected tab is a bit difficult to spot when there are many tabs:


Take a look at PlasticLookAndFeel and Options classes and try all the options. You might find nice things for your UI :)

Related Topics >>