| java.lang.Object com.jidesoft.plaf.LookAndFeelFactory
LookAndFeelFactory | public class LookAndFeelFactory implements ProductNames(Code) | | 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.
Bascially, 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 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 OSX, 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
LookAndFeelFactory.VSNET_STYLE ,
LookAndFeelFactory.ECLIPSE_STYLE ,
LookAndFeelFactory.ECLIPSE3X_STYLE ,
LookAndFeelFactory.OFFICE2003_STYLE , or
LookAndFeelFactory.XERTO_STYLE . 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.
LookAndFeelFactory supports a number of known L&Fs. You can see those L&Fs as constants whose names are
something like "_LNF" such as WINDOWS_LNF.
If you are using a 3rd party L&F we are not officially supporting, we might need to customize it. Here are two classes you can use.
The first one is
UIDefaultsCustomizer . You can add a number of customizers to LookAndFeelFactory. After LookAndFeelFactory
installJideExtension method is called, we will call customize() method on each UIDefaultsCustomizer to add additional UIDefaults
you specified. You can use UIDefaultsCustomizer to do things like small tweaks to UIDefaults without the hassle of creating a new style.
Most likely, we will not need to use
UIDefaultsInitializer if you are use L&Fs such as WindowsLookAndFeel,
any L&Fs based on MetalLookAndFeel, or AquaLookAndFeel etc. The only exception is Synth L&F and any L&Fs based on it. The reason is we
calcualte all colors we will use in JIDE components from existing wel-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 Synthethica L&F.
LookAndFeelFactory.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()
|
Inner Class :public static interface UIDefaultsCustomizer | |
Inner Class :public static interface UIDefaultsInitializer | |
Inner Class :public static class GTKInitializer implements UIDefaultsInitializer | |
Inner Class :public static class SyntheticaInitializer implements UIDefaultsInitializer | |
Inner Class :public static class SyntheticaCustomizer implements UIDefaultsCustomizer | |
A03_LNF | final public static String A03_LNF(Code) | | Class name of A03 L&F.
|
ALLOY_LNF | final public static String ALLOY_LNF(Code) | | Class name of Quaqua Alloy L&F.
|
AQUA_LNF | final public static String AQUA_LNF(Code) | | Class name of Aqua L&F provided in Apple Mac OSX JDK.
|
ECLIPSE3X_STYLE | final public static int ECLIPSE3X_STYLE(Code) | | A style that you can use with
LookAndFeelFactory.installJideExtension(int) method.
This style mimics the visual style of Eclipse 3.x for the toolbars, menus and dockable windows.
Eclipse 3x style works for almost all L&Fs and on any operating systems, although it looks the best on Windows.
For any other OS's we suggest you to use XERTO_STYLE or VSNET_STYLE.
UIManager.setLookAndFeel(AnyLookAndFeel.class.getName()); // you need to catch the exceptions on this call.
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.ECLIPSE3X_STYLE);
|
ECLIPSE_STYLE | final public static int ECLIPSE_STYLE(Code) | | A style that you can use with
LookAndFeelFactory.installJideExtension(int) method.
This style mimics the visual style of Eclipse 2.x for the toolbars, menus and dockable windows.
Eclipse style works for almost all L&Fs and on any operating systems, although it looks the best on Windows.
For any other operating systems we suggest you to use XERTO_STYLE or VSNET_STYLE.
Here is the code to set to any L&F with Eclipse style extension.
UIManager.setLookAndFeel(AnyLookAndFeel.class.getName()); // you need to catch the exceptions on this call.
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.ECLIPSE_STYLE);
|
GTK_LNF | final public static String GTK_LNF(Code) | | Class name of GTK L&F provided by Sun JDK.
|
JIDE_EXTENSION_INSTALLLED | final public static String JIDE_EXTENSION_INSTALLLED(Code) | | If installJideExtension is called, it will put an entry on UIDefaults table. UIManagerLookup.getBoolean(JIDE_EXTENSION_INSTALLLED) will
return true. You can also use
LookAndFeelFactory.isJideExtensionInstalled() to check the value instead of using UIManagerLookup.getBoolean(JIDE_EXTENSION_INSTALLLED).
|
JIDE_STYLE_INSTALLED | final public static String JIDE_STYLE_INSTALLED(Code) | | If installJideExtension is called, a JIDE style will be installed on UIDefaults table. If so, UIManagerLookup.getInt(JIDE_STYLE_INSTALLED)
will return you the style that is installed. For example, if the value is 1, it means VSNET_STYLE is installed because 1 is the value of VSNET_STYLE.
|
METAL_LNF | final public static String METAL_LNF(Code) | | Class name of Metal L&F provided in Sun JDK.
|
OFFICE2003_STYLE | final public static int OFFICE2003_STYLE(Code) | | A style that you can use with
LookAndFeelFactory.installJideExtension(int) method.
This style mimics the visual style of Microsoft Office2003 for the toolbars, menus and dockable windows.
Office2003 style looks great on Windows XP when Windows or Windows XP L&F from Sun JDK is used. It replicated
the exact same style as Microsoft Office 2003, to give your end user a familar visual style.
Here is the code to set to Windows L&F with Office2003 style extension.
UIManager.setLookAndFeel(WindowsLookAndFeel.class.getName()); // you need to catch the exceptions on this call.
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.OFFICE2003_STYLE);
It works either on any other Windows such as Winodows 2000, Windows 98 etc.
If you are on Windows XP, Office2003 style will change theme based on the theme setting in Windows Display Property.
But if you are not on XP, Office2003 style will use the default gray theme only. You can force to change it using
Office2003Painter.setColorName(String) method, but it won't look good as other non-JIDE components won't have
the matching theme.
Office2003 style doesn't work on any operating systems other than Windows mainly because the design of Office2003 style is so
centric to Windows that it doesn't look good on other operating systems.
|
PGS_LNF | final public static String PGS_LNF(Code) | | Class name of Pgs L&F.
|
PLASTIC3D_LNF | final public static String PLASTIC3D_LNF(Code) | | Class name of Plastic3D L&F before JGoodies Look 1.3 release.
|
PLASTIC3D_LNF_1_3 | final public static String PLASTIC3D_LNF_1_3(Code) | | Class name of Plastic3D L&F after JGoodies Look 1.3 release.
|
PLASTICXP_LNF | final public static String PLASTICXP_LNF(Code) | | Class name of PlasticXP L&F.
|
QUAQUA_LNF | final public static String QUAQUA_LNF(Code) | | Class name of Quaqua L&F.
|
SYNTHETICA_LNF | final public static String SYNTHETICA_LNF(Code) | | Class name of Synthetica L&F.
|
TONIC_LNF | final public static String TONIC_LNF(Code) | | Class name of Tonic L&F.
|
VSNET_STYLE | final public static int VSNET_STYLE(Code) | | A style that you can use with
LookAndFeelFactory.installJideExtension(int) method.
This style mimics the visual style of Microsoft Visuasl Studio .NET for the toolbars, menus and dockable windows.
Vsnet style is a very simple style with no gradient. Although it works on almost all L&Fs in any operating systems, it looks the best
on Windows 2000 or 98, or on Windows XP when XP theme is not on. If XP theme is on, we suggest you use Office2003 style or Xerto style.
Since the style is so simple, it works with a lot of the 3rd party L&F such as Tonic, Pgs, Alloy etc without causing too much noice.
That's why this is also the default style for any L&Fs we don't recognize when you call
LookAndFeelFactory.installJideExtension() ,
the one with out style parameter. If you would like another style to be used as the default style, you can call
LookAndFeelFactory.setDefaultStyle(int) method.
Here is the code to set to Windows L&F with Vsnet style extension.
UIManager.setLookAndFeel(WindowsLookAndFeel.class.getName()); // you need to catch the exceptions on this call.
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.VSNET_STYLE);
There is a special system property "shading theme" you can use. If you turn it on using the code below, you will see
a graident on dockable frame's title pane and rounded corner and graident on the tabs of JideTabbedPane.
So if the L&F you are using uses graident, you can set this property to true to match with your L&F. For example, if you use
Plastic3D L&F, turning this property on will look better.
System.setProperty("shadingtheme", "true");
|
WINDOWS_LNF | final public static String WINDOWS_LNF(Code) | | Class name of Windows L&F provided in Sun JDK.
|
XERTO_STYLE | final public static int XERTO_STYLE(Code) | | A style that you can use with
LookAndFeelFactory.installJideExtension(int) method.
This style is created by Xerto (http://www.xerto.com) which is used in their Imagery product.
Xerto style looks great on Windows XP when Windows XP L&F from Sun JDK is used.
Here is the code to set to Windows L&F with Xerto style extension.
UIManager.setLookAndFeel(WindowsLookAndFeel.class.getName()); // you need to catch the exceptions on this call.
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE);
Although it looks the best on Windows, Xerto style also supports Linux or Solaris if you use any L&Fs based
on Metal L&F or Synth L&F. For example, we recommend you to use Xerto style as default if you use SyntheticaL&F, a L&F based on Synth.
To use it, you bascially replace WindowsLookAndFeel to the L&F you want to use in setLookAndFeel line above.
|
XERTO_STYLE_WITHOUT_MENU | final public static int XERTO_STYLE_WITHOUT_MENU(Code) | | A style that you can use with
LookAndFeelFactory.installJideExtension(int) method. This style is the same as XERTO_STYLE
except it doesn't have menu related UIDefaults. You can only use this style if you didn't use any component from JIDE Action Framework.
Please note, we only use menu extension for Xerto style when the underlying L&F is Windows L&F. If you are using L&F such as Metal or other 3rd party L&F based on Metal,
XERTO_STYLE_WITHOUT_MENU will be used even you use XERTO_STYLE when calling to installJideExtension().
See Also: LookAndFeelFactory.XERTO_STYLE |
LookAndFeelFactory | protected LookAndFeelFactory()(Code) | | |
addUIDefaultsCustomizer | public static void addUIDefaultsCustomizer(UIDefaultsCustomizer uiDefaultsCustomizer)(Code) | | Adds your own UIDefaults customizer. This customizer will be called
after installJideExtension() is called.
For example, we use "JideButton.font" as the UIDefault for the JideButton font. If you want to use another font, you can do
LookAndFeelFactory.addUIDefaultsCustomizer(new LookAndFeelFactory.UIDefaultsCustomizer() {
public void customize(UIDefaults defaults) {
defaults.put("JideButton.font", whateverFont);
}
});
Parameters: uiDefaultsCustomizer - the UIDefaultsCustomizer |
addUIDefaultsInitializer | public static void addUIDefaultsInitializer(UIDefaultsInitializer uiDefaultsInitializer)(Code) | | Adds your own UIDefaults initializer. This initializer will be called
before installJideExtension() is called.
Here is how you use it. For example, we use the color of UIDefault "activeCaption" to get the active title color
which we will use for active title bar color in JIDE components. If the L&F you are using
doesn't set this UIDefault, we might throw NPE later in the code.
To avoid this, you call
LookAndFeelFactory.addUIDefaultsInitializer(new LookAndFeelFactory.UIDefaultsInitializer() {
public void initialize(UIDefaults defaults) {
defaults.put("activeCaption", whateverColor);
}
});
UIManager.setLookAndFeel(...); // set whatever L&F
LookAndFeelFactory.installJideExtension(); // install the UIDefaults needed by the JIDE components
Parameters: uiDefaultsInitializer - the UIDefaultsInitializer. |
getDefaultStyle | public static int getDefaultStyle()(Code) | | Gets the default style. If you never set default style before, it will return OFFICE2003_STYLE
if you are on Windows XP, L&F is instance of Windows L&F and XP theme is on. Otherwise, it will return VSNET_STYLE.
If you set default style before, it will return whatever style you set.
the default style. |
getLookAndFeel | public static LookAndFeel getLookAndFeel()(Code) | | Gets current L&F.
the current L&F. |
getProductsUsed | public static int getProductsUsed()(Code) | | |
getStyle | public static int getStyle()(Code) | | Gets current style.
the current style. |
getUIDefaultsCustomizers | public static UIDefaultsCustomizer[] getUIDefaultsCustomizers()(Code) | | Gets all UIDefaults customizers.
an array of UIDefaults customizers. |
getUIDefaultsInitializers | public static UIDefaultsInitializer[] getUIDefaultsInitializers()(Code) | | Gets all UIDefaults initializers.
an array of UIDefaults initializers. |
installDefaultLookAndFeel | public static void installDefaultLookAndFeel()(Code) | | Install the default L&F. In this method, we will look at system property "swing.defaultlaf" first.
If the value is set and it's not an instance of Synth L&F, we will use it. Otherwise, we will
use Metal L&F is OS is Linux or UNIX and use UIManager.getSystemLookAndFeelClassName() for other OS.
|
installDefaultLookAndFeelAndExtension | public static void installDefaultLookAndFeelAndExtension()(Code) | | Install the default L&F. In this method, we will look at system property "swing.defaultlaf" first.
If the value is set and it's not an instance of Synth L&F, we will use it. Otherwise, we will
use Metal L&F is OS is Linux or UNIX and use UIManager.getSystemLookAndFeelClassName() for other OS.
In addition, we will add JIDE extension to it.
|
installJideExtension | public static void installJideExtension()(Code) | | Adds additional UIDefaults JIDE needed to UIDefault table. You must call this method
everytime switching look and feel. And callupdateComponentTreeUI() in corresponding DockingManager
or DockableBarManager after this call.
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
catch (InstantiationException e) {
e.printStackTrace();
}
catch (IllegalAccessException e) {
e.printStackTrace();
}
catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
// to add attitional UIDefault for JIDE components
LookAndFeelFactory.installJideExtension(); // use default style VSNET_STYLE. You can change to a different style
using setDefaultStyle(int style) and then call this method. Or simply call installJideExtension(style).
// call updateComponentTreeUI
frame.getDockableBarManager().updateComponentTreeUI();
frame.getDockingManager().updateComponentTreeUI();
|
installJideExtension | public static void installJideExtension(int style)(Code) | | Add additional UIDefaults JIDE needed to UIDefaults table. You must call this method
everytime switching look and feel. And call updateComponentTreeUI() in corresponding DockingManager
or DockableBarManager after this call.
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
catch (InstantiationException e) {
e.printStackTrace();
}
catch (IllegalAccessException e) {
e.printStackTrace();
}
catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
// to add attitional UIDefault for JIDE components
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.OFFICE2003_STYLE);
// call updateComponentTreeUI
frame.getDockableBarManager().updateComponentTreeUI();
frame.getDockingManager().updateComponentTreeUI();
Parameters: style - the style of the extension. |
installJideExtension | public static void installJideExtension(UIDefaults uiDefaults, LookAndFeel lnf, int style)(Code) | | Installs the UIDefault needed by JIDE component to the uiDefaults table passed in.
Parameters: uiDefaults - the UIDefault tables where JIDE UIDefaults will be installed. Parameters: lnf - the LookAndFeel. This may have an effect on which set of JIDE UIDefaults we will install. Parameters: style - the style of the JIDE UIDefaults. |
isA03LnfInstalled | public static boolean isA03LnfInstalled()(Code) | | Returns whether A03 L&F is in classpath
true A03 L&F is in classpath, false otherwise |
isAlloyLnfInstalled | public static boolean isAlloyLnfInstalled()(Code) | | Returns whether alloy L&F is in classpath
true alloy L&F is in classpath, false otherwise |
isAquaLnfInstalled | public static boolean isAquaLnfInstalled()(Code) | | Returns whether or not the Aqua L&F is in classpath.
true if aqua L&F is in classpath, false otherwise |
isGTKLnfInstalled | public static boolean isGTKLnfInstalled()(Code) | | Returns whether GTK L&F is in classpath
true GTK L&F is in classpath, false otherwise |
isJideExtensionInstalled | public static boolean isJideExtensionInstalled()(Code) | | Checks if JIDE extension is installed. Please note, UIManager.setLookAndFeel() method will
overwrite the whole UIDefaults table. So even you called
LookAndFeelFactory.installJideExtension() method before,
UIManager.setLookAndFeel() method make isJideExtensionInstalled returning false.
true if installed. |
isPgsLnfInstalled | public static boolean isPgsLnfInstalled()(Code) | | Returns whether or not the Pgs L&F is in classpath.
true if pgs L&F is in classpath, false otherwise |
isPlastic3D13LnfInstalled | public static boolean isPlastic3D13LnfInstalled()(Code) | | Returns whether Plastic3D L&F is in classpath
true Plastic3D L&F is in classpath, false otherwise |
isPlastic3DLnfInstalled | public static boolean isPlastic3DLnfInstalled()(Code) | | Returns whether Plastic3D L&F is in classpath
true Plastic3D L&F is in classpath, false otherwise |
isPlasticXPLnfInstalled | public static boolean isPlasticXPLnfInstalled()(Code) | | Returns whether PlasticXP L&F is in classpath
true Plastic3D L&F is in classpath, false otherwise |
isQuaquaLnfInstalled | public static boolean isQuaquaLnfInstalled()(Code) | | Returns whether or not the Quaqua L&F is in classpath.
true if Quaqua L&F is in classpath, false otherwise |
isSyntheticaLnfInstalled | public static boolean isSyntheticaLnfInstalled()(Code) | | Returns whether or not the Synthetica L&F is in classpath.
true if Synthetica L&F is in classpath, false otherwise |
isTonicLnfInstalled | public static boolean isTonicLnfInstalled()(Code) | | Returns whether Tonic L&F is in classpath
true Tonic L&F is in classpath, false otherwise |
overwriteDefaults | public static void overwriteDefaults(UIDefaults table, Object[] keyValueArray)(Code) | | Puts a list of UIDefault to the UIDefaults table.
The keyValueList is an array with a key and value in pair. If the value is
null, this method will remove the key from the table. Otherwise, it will put the new value
in even if the table already has a value for the key. This is the difference from
LookAndFeelFactory.putDefaults(javax.swing.UIDefaults,Object[]) method.
You should use this method in
UIDefaultsCustomizer because you always want to override the existing value using the new value.
Parameters: table - the ui defaults table Parameters: keyValueArray - the key value array. It is in the format of a key followed by a value. |
putDefaults | public static void putDefaults(UIDefaults table, Object[] keyValueArray)(Code) | | Puts a list of UIDefault to the UIDefaults table.
The keyValueList is an array with a key and value in pair. If the value is
null, this method will remove the key from the table. If the table already has a value for
the key, the new value will be ignored. This is the difference from
LookAndFeelFactory.putDefaults(javax.swing.UIDefaults,Object[]) method.
You should use this method in
UIDefaultsInitializer so that it fills in the UIDefault value only when it is missing.
Parameters: table - the ui defaults table Parameters: keyValueArray - the key value array. It is in the format of a key followed by a value. |
removeUIDefaultsCustomizer | public static void removeUIDefaultsCustomizer(UIDefaultsCustomizer uiDefaultsCustomizer)(Code) | | Removes an existing UIDefaults customizer you added before.
Parameters: uiDefaultsCustomizer - the UIDefaultsCustomizer |
removeUIDefaultsInitializer | public static void removeUIDefaultsInitializer(UIDefaultsInitializer uiDefaultsInitializer)(Code) | | Removes an existing UIDefaults initializer you added before.
Parameters: uiDefaultsInitializer - the UIDefaultsInitializer |
setDefaultStyle | public static void setDefaultStyle(int defaultStyle)(Code) | | Sets the default style. If you call this method to set a default style,
LookAndFeelFactory.installJideExtension() will
use it as the default style.
Parameters: defaultStyle - the default style. |
setProductsUsed | public static void setProductsUsed(int productsUsed)(Code) | | Sets the products you will use. This is needed so that LookAndFeelFactory knows what UIDefault to initialize.
For example, if you use only JIDE Docking Framework and JIDE Grids, you should call
setProductUsed(ProductNames.PRODUCT_DOCK | ProductNames.PRODUCT_GRIDS) so that we don't initialize
UIDefaults needed by any other products. If you use this class as part of JIDE Common Layer open source
project, you should call setProductUsed(ProductNames.PRODUCT_COMMON) . If you want to use all JIDE products,
you should call setProductUsed(ProductNames.PRODUCT_ALL)
Parameters: productsUsed - a bit-wise OR of product values defined in com.jidesoft.utils.ProductNames. |
|
|