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
LookAndFeeland extending each of the UI delegates defined injavax.swing.plaf.Extend the
BasicLookAndFeeland each of the abstract UI delegates defined injavax.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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access