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 ...

Get Java Swing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.