Creation of a Custom Look-and-Feel
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 L&F. As you might guess, this is not something you’ll do in an afternoon, nor is it usually something you should consider doing at all. However, thanks to the L&F framework, it’s not as difficult as you might think. In a few instances, it actually makes sense, such as when you’re developing a game. You’ll likely find that the most difficult part is coming up with a graphical design for each component.
There are basically three different strategies for creating a new L&F:
Start from scratch 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 as an abstract framework ...
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