 |
Collaboration between two look-and-feel projects
Posted by kirillcool on August 30, 2005 at 01:43 PM | Comments (6)
Werner
Randelshofer is the developer of very popular Quaqua look and feel. As said on the project main page, Quaqua is focused on fixing minor bugs and glitches in Apple's implementation of the AHIG as well as providing enhancements that make your application fit nicely into Mac OS X. Unfortunately, this excellent look and feel is available for Macintosh only, and until the last release, there wasn't a lot of code which could have been shared with other platforms.
However, the new release 3.3 features an excellent implementation of color chooser dialog UI delegate (see left screenshot below), the first sight of which immediately made me want to have such delegate in my own Substance look and feel (which takes many of its ideas from Mac 10.4 already). Two choices presented themselves immediately: reinvent the wheel or ask to share the code. Undoubtedly, the first choice would be the choice of many open-source developers - a nice-looking wheel waiting to be reinvented. This would mean, of course, an inevitable peek at the source code, and a well-known dilemma, to copy as is or to pretend that you are writing something completely new while you are looking at somebody else's code all along. The second way involves a simple question ("Would you be kind enough to allow sharing some of your code as long as the licenses match and the copyright / credits are in place?"), a short wait, and a sigh of relief when the positive answer comes through.
The sigh of relief stems from many reasons.
- The code already exists, and fits my needs nicely (otherwise why would I want to use it).
- Somebody else wrote it and actively maintains it, so any bugs will be fixed (hopefully) by that person :), even double smiley :-)
- New features / enhancements / versions will be incorporated as is (giving added value to your code without a lot of investment on your part)
- Last but not the least - this is the essence of open source. Share, share, share. And reuse.
The whole process took about two hours, of which
- Five minutes were spent on extracting the relevant package for color chooser components, additional helper classes and setting five properties in the UIManager
- An hour on creating a crayon palette (bottom-right on the right image), as the original palette is most probably copyrighted by Apple
- An hour on creating listeners for custom sliders of Quaqua color chooser panels for rollover effects (to be consistent with the rest of Substance look and feel.
And finally, the results (Quaqua on Macintosh on the left, Substance on Windows XP on the right):
You can try the Web Start version of Substance look and feel test application (go to Dialogs tab and click Color button). Note that you will need Tiger+ for running this application
Technorati Profile
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
I ran the webstart version, locked the pc (XPsp2) and went home. Next day, unlocked the PC and all the buttons were missing and only got repainted when mousing over where they should have been.
Also, aesthetically, can you make the buttons in Substance look more like the OSX ones? they just look very dated now - closer to the way OSX 10.0 looked.
Otherwise, very nice.
Oh, just noticed... you don't support the native OSX palette mode where you can use your own image into the swatch area. I use that quite a lot where I want to pick colours from an existing image.
Posted by: goron on September 01, 2005 at 02:58 AM
-
goron,
About missing buttons - that's most probably Swing, as the UI only provides paint() functions and not the paint invocation itself.
About OSX buttons look - although it could be said that Substance tries to mimic Mac 10.4, it's only partially correct. I took a lot of graphics idea from there, but it's not pixel-fidelity. As such, i'm not thinking about providing OSX feel for all platforms.
About ColorChooser palette - the whole point of this entry was to show that the code belongs to Quaqua. If you have a request, you are welcome to contact Werner (although most probably he will not do it as he is doing Mac emulation with this UI).
Posted by: kirillcool on September 01, 2005 at 03:46 AM
-
1. "Minimize" button stay hilighted when I minimize JInternalFrame on "Desktop" tab of test demo and then restore it.
2. I ran then test demo and it worked ok. But it failed when I add command line key
-Dswing.defaultlaf=org.jvnet.substance.SubstanceLookAndFeel
into test.bat.
Text of error message is
Exception in thread "main" java.lang.Error: can't load org.jvnet.substance.SubstanceLookAndFeel
at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1176)
at javax.swing.UIManager.initialize(UIManager.java:1257)
at javax.swing.UIManager.maybeInitialize(UIManager.java:1245)
at javax.swing.UIManager.getLookAndFeelDefaults(UIManager.java:872)
at org.jvnet.substance.SubstanceLookAndFeel.setCurrentTheme(SubstanceLookAndFeel.java:109)
at org.jvnet.substance.SubstanceLookAndFeel.(SubstanceLookAndFeel.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:481)
at test.Check.main(Check.java:1675)
This error take place with any other programs when I use this command line key. Substance plaf is in classpath.
Environment:
Windows 2000 SP4
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
Posted by: maslikhin on September 01, 2005 at 11:39 PM
-
maslikhin,
I have tested many configurations with swing.defaultlaf flag, and they all worked. Can you print the System.getProperty("java.class.path") and see that the substance.jar is there?
I'll test the minimize button issue in JInternalFrame, and if this is a bug, i'll file an issue and handle it.
Thanks for reporting, and you are welcome to use issue tracker on the main project page (on the left hand side) - if you have time, of course :)
Posted by: kirillcool on September 02, 2005 at 05:59 AM
-
maslikhin,
The minimize button was indeed a defect and it has been fixed. Thanks again for reporting.
Posted by: kirillcool on September 02, 2005 at 06:25 AM
-
maslikhin,
The second issue (swing.defaultlaf) was also a bug (very quirky, as setCurrentTheme is called twice by Swing, the first time with null UI defaults table). It was fixed. Thanks.
Posted by: kirillcool on September 03, 2005 at 01:31 AM
|