Using Thirdparty Look-and-Feel in NetBeans RCP Application
I am trying to apply a thirdparty LAF to a NetBeans RCP application (not the IDE). Because this is a thirdparty LAF, I have to include a dependency on an additional JAR. Being a modular platform, I wrote a NetBeans module that wraps the LAF JAR and calls UIManager.setLookAndFeel() in the restored() method. The problem is modules are not loaded in any particular order so it doesn't work all the time.
Ideall开发者_运维百科y I would force this module to load immediately but I couldn't find how to do that cleanly.
I had tried setting the LAF with the "--laf" and "--cp:p" arguments as described here:
http://javahowto.blogspot.com/2008/05/how-to-customize-netbeans-look-and-feel.html
The problem is the thirdparty LAF JAR depends on NetBeans and other thirdparty JARs so at runtime I get a lot of "class not found" errors. Technically those classes are present but in separate modules. I'd prefer to not clutter up the command line with numerous "--cp:p" arguments.
As a side note, by having the IDE and RCP having the same name it makes Googling for solutions much harder.
Further debugging revealed the RCP calling UIManager.setLookAndFeel() a couple more times after my LAF module was started. Those subsequent calls were resetting the LAF back to the default.
The "--laf" command line argument did not affect the default LAF. However setting the "swing.defaultlaf" system property did.
The solution was to also set that system property in the module's restored() method to the thirdparty LAF class name.
精彩评论