JIDE Software created many new components that need their own ComponentUI classes and additional UIDefaults in
UIDefaults table. LookAndFeelFactory can take the UIDefaults from any existing look and feel and add the extra
UIDefaults JIDE components need.
Before using any JIDE components, please make you call one of the two LookAndFeelFactory.installJideExtension(...)
methods. Basically, you set L&F using UIManager first just like before, then call installJideExtension. See code
below for an example.
UIManager.setLookAndFeel(WindowsLookAndFeel.class.getName()); // you need to catch the exceptions on this call.
LookAndFeelFactory.installJideExtension();
LookAndFeelFactory.installJideExtension() method will check what kind of L&F you set and what operating system you
are on and decide which style of JIDE extension it will install. Here is the rule.
- OS: Windows Vista or
Windows 7, L&F: Windows L&F => OFFICE2007_STYLE
- OS: Windows XP with XP theme on, L&F: Windows L&F =>
OFFICE2003_STYLE
- OS: any Windows, L&F: Windows L&F => VSNET_STYLE
- OS: Linux, L&F: any L&F based on Metal
L&F => VSNET_STYLE
- OS: Mac OS X, L&F: Aqua L&F => AQUA_STYLE
- OS: any OS, L&F: Quaqua L&F => AQUA_STYLE
-
Otherwise => VSNET_STYLE
There is also another installJideExtension which takes an int style parameter. You can
pass in
#EXTENSION_STYLE_VSNET,
#EXTENSION_STYLE_ECLIPSE,
#EXTENSION_STYLE_ECLIPSE3X,
#EXTENSION_STYLE_OFFICE2003,
#EXTENSION_STYLE_OFFICE2007, or
#EXTENSION_STYLE_XERTO,
#EXTENSION_STYLE_OFFICE2003_WITHOUT_MENU,
#EXTENSION_STYLE_OFFICE2007_WITHOUT_MENU,
#EXTENSION_STYLE_ECLIPSE_WITHOUT_MENU,
#EXTENSION_STYLE_ECLIPSE3X_WITHOUT_MENU. In the other word, you will
make the choice of style instead of letting LookAndFeelFactory to decide one for you. Please note, there is no
constant defined for AQUA_STYLE. The only way to use it is when you are using Aqua L&F or Quaqua L&F and you call
installJideExtension() method, the one without parameter.
Another way is to call
LookAndFeelFactory#installDefaultLookAndFeelAndExtension() which will set the default
L&Fs based on the OS and install JIDE extension.
LookAndFeelFactory supports a number of known L&Fs. Some are L&Fs in the JDK such as Metal, Windows, Aqua (on Apple
JDK only), GTK. We also support some 3rd party L&Fs such as Plastic XP or Plastic 3D, Tonic, A03, Synthetica etc.
If you are using a 3rd party L&F we are not officially supporting, you might need to customize it. Here are two
classes you can use -
LookAndFeelFactory.UIDefaultsInitializer and
LookAndFeelFactory.UIDefaultsCustomizer.
Let's start with UIDefaultsCustomizer. No matter what unknown L&F you are trying to use, LookAndFeelFactory's
installJideExtension() will try to install the UIDefaults that JIDE components required. Hopefully JIDE will run on
your L&F without any exception. But most likely, it won't look very good. That's why you need
UIDefaultsCustomizer to customize the UIDefaults.
Most likely, you will not need to use
UIDefaultsInitializer. The only exception is Synth L&F and any L&Fs
based on it. The reason is we calculate all colors we will use in JIDE components from existing well-known
UIDefaults. For example, we will use UIManagerLookup.getColor("activeCaption") to calculate a color that we can use
in dockable frame's title pane. We will use UIManagerLookup.getColor("control") to calculate a color that we can use
as background of JIDE component. Most L&Fs will fill those UIDefaults. However in Synth L&F, those UIDefaults may or
may not have a valid value. You will end up with NPE later in the code when you call installJideExtension. In this
case, you can add those extra UIDefaults in UIDefaultsInitializer. We will call it before installJideExtension is
called so that those UIDefaults are there ready for us to use. This is how added support to GTK L&F and Synthetica
L&F.
After you create your own UIDefaultsCustomizer or Initializer, you can call
#addUIDefaultsCustomizer(com.jidesoft.plaf.LookAndFeelFactory.UIDefaultsCustomizer) or
#addUIDefaultsInitializer(com.jidesoft.plaf.LookAndFeelFactory.UIDefaultsInitializer) which will make the customizer
or the initializer triggered all the times. If you only want it to be used for a certain L&F, you should use
#registerDefaultCustomizer(String,String) or
#registerDefaultInitializer(String,String).
By default, we also use UIDefaultsCustomizer and UIDefaultsInitializer internally to provide support for non-standard
L&Fs. However we look into the classes under "com.jidesoft.plaf" package for default customizers and initializers.
For example, for PlasticXPLookAndFeel, the corresponding customizer is "oom.jidesoft.plaf.plasticxp.PlasticXPCustomizer".
We basically take the L&F name "PlasticXP", append it after "com.jidesoft.plaf" using lower case to get package name,
take the L&F name, append with "Customizer" to get the class name. We will look at PlasticXPLookAndFeel's super class
which is PlasticLookAndFeel. The customizer corresponding to PlasticLookAndFeel is
"com.jidesoft.plaf.plastic.PlasticCustomizer". This searching process continues till we find all super classes of a
L&F. Then we start from its top-most super class and call the customizers one by one, if it is there. The
src-plaf.jar or src-plaf-jdk7.jar contain some of these customizers. You could use this naming pattern to create the
customizers so that you don't need to register them explicitly.
#installJideExtension() method will only add the additional UIDefaults to current ClassLoader. If you have
several class loaders in your system, you probably should tell the UIManager to use the class loader that called
installJideExtension
. Otherwise, you might some unexpected errors. Here is how to specify the class
loaders.
UIManager.put("ClassLoader", currentClass.getClassLoader()); // currentClass is the class where the code is.
LookAndFeelFactory.installDefaultLookAndFeelAndExtension(); // or installJideExtension()