O'Reilly logo

Java Swing by Dave Wood, Marc Loy, Robert Eckstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creation of a Custom L&F

Everything we’ve covered in this chapter up to this point has been useful background information for the ultimate application customization strategy—creating your own look-and-feel. As you might guess, this is not something you’ll do in an afternoon. However, thanks to the improvements made in the L&F framework (as of the JDK 1.2 beta 4 release), it’s not as difficult as you might think. You’ll likely find that the most difficult part is coming up with graphical design for each component.

There are basically three different strategies for creating a new L&F:

  • Start from ground zero by extending LookAndFeel and extending each of the UI delegates defined in javax.swing.plaf.

  • Extend the BasicLookAndFeel and each of the abstract UI delegates defined in javax.swing.plaf.basic.

  • Extend an existing L&F, like MetalLookAndFeel, and change only selected components.

The first option gives you complete control over how everything works. It also requires a lot of effort. Unless you are implementing an L&F that is fundamentally different from the traditional desktop L&Fs, or you have some strong desire to implement your own L&F framework from scratch, we strongly recommend that you do not use this approach.

The next option is the most logical if you want to create a completely new L&F. This is the approach we’ll focus on in this section. The BasicLookAndFeel has been designed (well, actually it’s been significantly re-designed as of JDK 1.2 beta 4) as an abstract framework for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required