[jsword-devel] Look and Feel Switching

DM Smith jsword-devel@crosswire.org
Tue, 09 Mar 2004 12:33:03 -0500


I noticed that JSword has support for switching the look and feel of the 
application.

I have found some subtle and odd behavior.

If you start the application in Windows LAF and then go to options and 
change it to Metal, you only get a partial change. This can easily be seen 
by bringing up a second copy of the application. The applications look 
significantly different. An odd behavior is that any widget created after 
the switch has the correct laf, but anything created before does not.

According to the Java Look and Feel Design Guide 2nd Edition 
(http://java.sun.com/products/jlf/ed2/book/index.html), Appendix D: 
Switching Look And Feel Design, switching is provided as a mechanism for 
developers and not for end users. Sun cautions against letting the user do 
the switching.

What led me to find this was reading up on winlaf to see what it provides. 
In looking at it I found that there was a discrepency between what it said 
it provided and what JSword did. In looking into it, I found that the LAF 
has to be installed before winlaf is installed. The application does the 
reverse. I also found that winlaf should only be installed if the laf is 
Windows.

If the user can switch the laf, I think it should be postponed until the 
next run of the application. As a courtesy maybe it would be nice to pop up 
a modal dialog box letting the user know it will occur at the next startup. 
If this is done, then most of the LookAndFeelUtil is not needed. 
Specifically, the methods setLookAndFeel(...), updateComponents, 
addComponentToUpdate and removeComponentToUpdate are not need.

If the laf is to be an option, I think it would also be nice to provide a 
pick list of the available lafs. I have found that this differs between OS. 
For example, I don't have a Mac laf on my Windows box
and on a Solaris workstation, Windows laf is not installable (it is there 
but disabled, supposedly for licensing reasons). So the pick list would need 
to be determined dynamically.

I also found a minor problem in the LookAndFeelUtil. In the static block, 
current is set to the System LookAndFeel, but actually at that time it is 
not installed. By default, Java starts out in the Metal laf and the 
application has to specifically request a change to the System laf or any 
other laf. So, "current" should be set to 
UIManager.getLookAndFeel().getClass();

I don't think that it matters, but unless the laf is set before the splash 
screen, the splash will have a metal look and feel. You can notice this in 
the color of the progress meter and in the font. It does not match the 
program when it is run in a Windows laf.

_________________________________________________________________
One-click access to Hotmail from any Web page – download MSN Toolbar now! 
http://clk.atdmt.com/AVE/go/onm00200413ave/direct/01/