Java Reference
In-Depth Information
Figure 20-7. UI delegate creation sequence diagram
Creating a New Look and Feel
Unless a company wants you to customize everything to provide a unique experience, it typically
isn't necessary to create a whole new look and feel from scratch. Usually, developers make
minor modifications to an existing look and feel by providing some customized UI delegates.
However, if you do want to create a new look and feel class, you just need to create a subclass
of the LookAndFeel class. You still must provide the UI delegates, but their classes can now be
more hidden from the Swing components, since their usage will not be known directly from
the javax.swing component class.
Using the WindowsLookAndFeel on a Non-Windows Machine
To demonstrate the creation of a new look and feel class, let's create a look and feel implemen-
tation that cancels out the platform requirement for the Windows UI delegate. By simply
overriding the public boolean isSupportedLookAndFeel() method to return true , you effec-
tively remove the platform requirement for the Windows look and feel class.
Note The Java license expressly forbids you from delivering applications that remove the platform
requirements for the Windows look and feel class. So, you can work through the example here, as long as
you don't deliver it.
The class definition in Listing 20-9 shows how simple the creation of a new look and feel
implementation can be.
 
Search WWH ::




Custom Search