Package com.jidesoft.plaf
Class LookAndFeelFactory
java.lang.Object
com.jidesoft.plaf.LookAndFeelFactory
- All Implemented Interfaces:
ProductNames
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
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 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 LookAndFeelFactory.UIDefaultsCustomizer
to customize the UIDefaults.
Most likely, you will not need to use LookAndFeelFactory.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()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
An interface to make the customization of UIDefaults easier.static interface
An interface to make the initialization of UIDefaults easier. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Class name of A03 L&F.static final String
Class name of Alloy L&F.static final String
Class name of Aqua L&F provided in Apple Mac OS X JDK.static final String
Class name of Aqua L&F provided in Apple Mac OS X JDK.static final String
Class name of Bizlaf L&F provided by Centigrade.static final String
Class name of Darcula L&F.static final int
The same asEXTENSION_STYLE_ECLIPSE
static final int
The same asEXTENSION_STYLE_ECLIPSE
static final int
A style that you can use withinstallJideExtension(int)
method.static final int
A style that you can use withinstallJideExtension(int)
method.static final int
A style that you can use withinstallJideExtension(int)
method.static final int
A style that you can use withinstallJideExtension(int)
method.static final int
A style that you can use withinstallJideExtension(int)
method.static final int
Deprecated.static final int
A style that you can use withinstallJideExtension(int)
method.static final int
Deprecated.static final int
A style that you can use withinstallJideExtension(int)
method.static final int
A style that you can use withinstallJideExtension(int)
method.static final int
A style that you can use withinstallJideExtension(int)
method.static final int
A style that you can use withinstallJideExtension(int)
method.static final String
Class name of GTK L&F provided by Sun JDK.static final String
If installJideExtension is called, it will put an entry on UIDefaults table.static final String
If installJideExtension is called, a JIDE style will be installed on UIDefaults table.static final String
static final String
static final String
Class name of Metal L&F provided in Sun JDK.static final String
Class name of Motif L&F provided by Sun JDK.static final String
The name of Nimbus L&F.static final int
The same asEXTENSION_STYLE_OFFICE2003
static final int
The same asEXTENSION_STYLE_OFFICE2007
static final String
Class name of Pgs L&F.static final String
Class name of Plastic3D L&F.static final String
Deprecated.replaced by PLASTIC3D_LNFstatic final String
Class name of PlasticXP L&F.static final String
Class name of Quaqua L&F.static final String
Class name of Synth L&F provided in Sun JDK.static final String
Class name of Synthetica L&F.static final String
static final String
Class name of Tonic L&F.static final int
The same asEXTENSION_STYLE_VSNET
static final int
The same asEXTENSION_STYLE_VSNET_WITHOUT_MENU
static final String
Class name of Windows L&F provided in Sun JDK.static final String
Class name of Windows L&F provided in Sun JDK.static final int
The same asEXTENSION_STYLE_XERTO
static final int
The same asEXTENSION_STYLE_XERTO_WITHOUT_MENU
Fields inherited from interface com.jidesoft.utils.ProductNames
COMPONENT_PRODUCTS, PRODUCT_ACTION, PRODUCT_ALL, PRODUCT_CHARTS, PRODUCT_CODE_EDITOR, PRODUCT_COMMON, PRODUCT_COMPONENTS, PRODUCT_DASHBOARD, PRODUCT_DATAGRIDS, PRODUCT_DIALOGS, PRODUCT_DIFF, PRODUCT_DOCK, PRODUCT_ENTERPRISE_SUITE, PRODUCT_FEEDREADER, PRODUCT_GANTT_CHART, PRODUCT_GRIDS, PRODUCT_JDAF, PRODUCT_NAME_ACTION, PRODUCT_NAME_CHARTS, PRODUCT_NAME_CODE_EDITOR, PRODUCT_NAME_COMMON, PRODUCT_NAME_COMPONENTS, PRODUCT_NAME_DASHBOARD, PRODUCT_NAME_DATAGRIDS, PRODUCT_NAME_DIALOGS, PRODUCT_NAME_DIFF, PRODUCT_NAME_DOCK, PRODUCT_NAME_FEEDREADER, PRODUCT_NAME_GANTT_CHART, PRODUCT_NAME_GRIDS, PRODUCT_NAME_JDAF, PRODUCT_NAME_PIVOT, PRODUCT_NAME_SHORTCUT, PRODUCT_NAME_TREEMAP, PRODUCT_PIVOT, PRODUCT_PROFESSIONAL_SUITE, PRODUCT_SHORTCUT, PRODUCT_SOLUTION, PRODUCT_TREEMAP, PRODUCT_ULTIMATE_SUITE, SOLUTION_PRODUCTS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addUIDefaultsCustomizer
(LookAndFeelFactory.UIDefaultsCustomizer uiDefaultsCustomizer) Adds your own UIDefaults customizer.static void
addUIDefaultsInitializer
(LookAndFeelFactory.UIDefaultsInitializer uiDefaultsInitializer) Adds your own UIDefaults initializer.static void
Clears all registered customizers.static void
Clears all registered initializers.static int
Gets the default style.static LookAndFeel
Gets current L&F.static int
static int
getStyle()
Gets current style.Gets all UIDefaults customizers.Gets all UIDefaults initializers.static ClassLoader
static void
Install the default L&F.static void
Install the default L&F.static void
Adds additional UIDefaults JIDE needed to UIDefault table.static void
installJideExtension
(int style) Add additional UIDefaults JIDE needed to UIDefaults table.static void
installJideExtension
(UIDefaults uiDefaults, LookAndFeel lnf, int style) Installs the UIDefault needed by JIDE component to the uiDefaults table passed in.static boolean
Returns whether A03 L&F is in classpathstatic boolean
Returns whether alloy L&F is in classpathstatic boolean
Returns whether or not the Aqua L&F is in classpath.static boolean
Returns whether Bizlaf L&F is in classpathstatic boolean
Checks if the current L&F uses decorated frames.static boolean
Returns whether Darcula L&F is in classpathstatic boolean
Returns whether GTK L&F is in classpathstatic boolean
Checks if JIDE extension is installed.static boolean
isLnfInstalled
(String lnfName) Returns whether or not the L&F is in classpath.static boolean
isLnfInUse
(String lnf) Checks if the L&F is the L&F or a subclass of the L&F.static boolean
Gets the flag indicating if JIDE will try to load the LnF class whenisLnfInstalled(String)
is invoked.static boolean
static boolean
Returns whether or not the Nimbus L&F is in classpath.static boolean
Returns whether or not the Pgs L&F is in classpath.static boolean
Deprecated.replace byisPlastic3DLnfInstalled()
static boolean
Returns whether Plastic3D L&F is in classpathstatic boolean
Returns whether PlasticXP L&F is in classpathstatic boolean
Returns whether or not the Quaqua L&F is in classpath.static boolean
Returns whether or not the Synthetica L&F is in classpath.static boolean
Returns whether Tonic L&F is in classpathstatic boolean
As of Java 10, com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel is no longer available on macOS thus "instanceof WindowsClassicLookAndFeel" directives will result in a NoClassDefFoundError during runtime.static boolean
As of Java 10, com.sun.java.swing.plaf.windows.WindowsLookAndFeel is no longer available on macOS thus "instanceof WindowsLookAndFeel" directives will result in a NoClassDefFoundError during runtime.static void
static void
overwriteDefaults
(UIDefaults table, Object[] keyValueArray) Puts a list of UIDefault to the UIDefaults table.static void
putDefaults
(UIDefaults table, Object[] keyValueArray) Puts a list of UIDefault to the UIDefaults table.static void
registerDefaultCustomizer
(String lnfClassName, String customizerClassName) Registers a UIDefaultsCustomizer with a L&F.static void
registerDefaultInitializer
(String lnfClassName, String initializerClassName) Registers a UIDefaultsInitializer with a L&F.static void
removeUIDefaultsCustomizer
(LookAndFeelFactory.UIDefaultsCustomizer uiDefaultsCustomizer) Removes an existing UIDefaults customizer you added before.static void
removeUIDefaultsInitializer
(LookAndFeelFactory.UIDefaultsInitializer uiDefaultsInitializer) Removes an existing UIDefaults initializer you added before.static void
setDefaultStyle
(int defaultStyle) Sets the default style.static void
setLnfInstalled
(String lnfName, boolean installed) Tells the LookAndFeelFactory whether a L&F is installed.static void
setLoadLookAndFeelClass
(boolean loadLookAndFeelClass) Sets the flag indicating if JIDE will try to load the L&F class whenisLnfInstalled(String)
is invoked.static void
setProductsUsed
(int productsUsed) Sets the products you will use.static void
unregisterDefaultCustomizer
(String lnfClassName) Unregisters a UIDefaultCustomizer for L&F.static void
unregisterDefaultInitializer
(String lnfClassName) Unregisters a UIDefaultsInitializer for L&F.static void
verifyDefaults
(UIDefaults table, Object[] keyValueList)
-
Field Details
-
WINDOWS_CLASSIC_LNF
Class name of Windows L&F provided in Sun JDK.- See Also:
-
WINDOWS_LNF
Class name of Windows L&F provided in Sun JDK.- See Also:
-
METAL_LNF
Class name of Metal L&F provided in Sun JDK.- See Also:
-
SYNTH_LNF
Class name of Synth L&F provided in Sun JDK.- See Also:
-
AQUA_LNF
Class name of Aqua L&F provided in Apple Mac OS X JDK.- See Also:
-
AQUA_LNF_6
Class name of Aqua L&F provided in Apple Mac OS X JDK. This is the new package since Java Update 6.- See Also:
-
QUAQUA_LNF
Class name of Quaqua L&F.- See Also:
-
ALLOY_LNF
Class name of Alloy L&F.- See Also:
-
SYNTHETICA_LNF
Class name of Synthetica L&F.- See Also:
-
SYNTHETICA_LNF_PREFIX
- See Also:
-
PLASTIC3D_LNF
Class name of Plastic3D L&F.- See Also:
-
PLASTIC3D_LNF_1_3
Deprecated.replaced by PLASTIC3D_LNFClass name of Plastic3D L&F after JGoodies Look 1.3 release.- See Also:
-
PLASTICXP_LNF
Class name of PlasticXP L&F.- See Also:
-
TONIC_LNF
Class name of Tonic L&F.- See Also:
-
A03_LNF
Class name of A03 L&F.- See Also:
-
DARCULA_LNF
Class name of Darcula L&F.- See Also:
-
PGS_LNF
Class name of Pgs L&F.- See Also:
-
GTK_LNF
Class name of GTK L&F provided by Sun JDK.- See Also:
-
MOTIF_LNF
Class name of Motif L&F provided by Sun JDK.- See Also:
-
BIZ_LNF
Class name of Bizlaf L&F provided by Centigrade.- See Also:
-
NIMBUS_LNF_NAME
The name of Nimbus L&F. We didn't create a constant for Nimbus is because the package name will be changed in JDK7 release- See Also:
-
VSNET_STYLE_WITHOUT_MENU
public static final int VSNET_STYLE_WITHOUT_MENUThe same asEXTENSION_STYLE_VSNET_WITHOUT_MENU
-
VSNET_STYLE
public static final int VSNET_STYLEThe same asEXTENSION_STYLE_VSNET
- See Also:
-
ECLIPSE_STYLE
public static final int ECLIPSE_STYLEThe same asEXTENSION_STYLE_ECLIPSE
- See Also:
-
OFFICE2003_STYLE
public static final int OFFICE2003_STYLEThe same asEXTENSION_STYLE_OFFICE2003
-
XERTO_STYLE
public static final int XERTO_STYLEThe same asEXTENSION_STYLE_XERTO
- See Also:
-
XERTO_STYLE_WITHOUT_MENU
public static final int XERTO_STYLE_WITHOUT_MENUThe same asEXTENSION_STYLE_XERTO_WITHOUT_MENU
-
ECLIPSE3X_STYLE
public static final int ECLIPSE3X_STYLEThe same asEXTENSION_STYLE_ECLIPSE
- See Also:
-
OFFICE2007_STYLE
public static final int OFFICE2007_STYLEThe same asEXTENSION_STYLE_OFFICE2007
-
EXTENSION_STYLE_VSNET_WITHOUT_MENU
public static final int EXTENSION_STYLE_VSNET_WITHOUT_MENUA style that you can use withinstallJideExtension(int)
method. This style is the same as VSNET_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.- See Also:
-
EXTENSION_STYLE_VSNET
public static final int EXTENSION_STYLE_VSNETA style that you can use withinstallJideExtension(int)
method. This style mimics the visual style of Microsoft Visual 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 noise. That's why this is also the default style for any L&Fs we don't recognize when you callinstallJideExtension()
, the one with out style parameter. If you would like another style to be used as the default style, you can callsetDefaultStyle(int)
method. Here is the code to set to Windows L&F with Vsnet style extension.
There is a special system property "shading theme" you can use. If you turn it on using the code below, you will see a gradient on dockable frame's title pane and rounded corner and gradient on the tabs of JideTabbedPane. So if the L&F you are using uses gradient, 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.UIManager.setLookAndFeel(WindowsLookAndFeel.class.getName()); // you need to catch the exceptions on this call. LookAndFeelFactory.installJideExtension(LookAndFeelFactory.EXTENSION_STYLE_VSNET);
System.setProperty("shadingtheme", "true");
- See Also:
-
EXTENSION_STYLE_ECLIPSE
public static final int EXTENSION_STYLE_ECLIPSEA style that you can use withinstallJideExtension(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 EXTENSION_STYLE_XERTO or EXTENSION_STYLE_VSNET. 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.EXTENSION_STYLE_ECLIPSE);
- See Also:
-
EXTENSION_STYLE_OFFICE2003
public static final int EXTENSION_STYLE_OFFICE2003A style that you can use withinstallJideExtension(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 familiar visual style. Here is the code to set to Windows L&F with Office2003 style extension.
It works either on any other Windows such asWindows 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 usingUIManager.setLookAndFeel(WindowsLookAndFeel.class.getName()); // you need to catch the exceptions on this call. LookAndFeelFactory.installJideExtension(LookAndFeelFactory.EXTENSION_STYLE_OFFICE2003);
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.- See Also:
-
EXTENSION_STYLE_XERTO
public static final int EXTENSION_STYLE_XERTOA style that you can use withinstallJideExtension(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.
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 basically replace WindowsLookAndFeel to the L&F you want to use in setLookAndFeel line above.UIManager.setLookAndFeel(WindowsLookAndFeel.class.getName()); // you need to catch the exceptions on this call. LookAndFeelFactory.installJideExtension(LookAndFeelFactory.EXTENSION_STYLE_XERTO);
- See Also:
-
EXTENSION_STYLE_ECLIPSE3X
public static final int EXTENSION_STYLE_ECLIPSE3XA style that you can use withinstallJideExtension(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 EXTENSION_STYLE_XERTO or EXTENSION_STYLE_VSNET.UIManager.setLookAndFeel(AnyLookAndFeel.class.getName()); // you need to catch the exceptions on this call. LookAndFeelFactory.installJideExtension(LookAndFeelFactory.EXTENSION_STYLE_ECLIPSE3X);
- See Also:
-
EXTENSION_STYLE_XERTO_WITHOUT_MENU
public static final int EXTENSION_STYLE_XERTO_WITHOUT_MENUA style that you can use withinstallJideExtension(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:
-
EXTENSION_STYLE_OFFICE2007
public static final int EXTENSION_STYLE_OFFICE2007A style that you can use withinstallJideExtension(int)
method. This style mimics the visual style of Microsoft Office2007 for the toolbars, menus and dockable windows. Office2007 style looks great on Windows Vista when Windows L&F from Sun JDK is used. It replicated the exact same style as Microsoft Office 2007, to give your end user a familiar visual style. Here is the code to set to Windows L&F with Office2007 style extension.
Office2007 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. Because we use some painting code that is only available in JDK6, Office 2007 style only runs if you are using JDK6 and above.UIManager.setLookAndFeel(WindowsLookAndFeel.class.getName()); // you need to catch the exceptions on this call. LookAndFeelFactory.installJideExtension(LookAndFeelFactory.EXTENSION_STYLE_OFFICE2007);
- See Also:
-
EXTENSION_STYLE_OFFICE2003_WITHOUT_MENU
Deprecated.A style that you can use withinstallJideExtension(int)
method. This style is the same as EXTENSION_STYLE_OFFICE2003 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. -
EXTENSION_STYLE_OFFICE2007_WITHOUT_MENU
Deprecated.A style that you can use withinstallJideExtension(int)
method. This style is the same as EXTENSION_STYLE_OFFICE2007 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. -
EXTENSION_STYLE_ECLIPSE_WITHOUT_MENU
public static final int EXTENSION_STYLE_ECLIPSE_WITHOUT_MENUA style that you can use withinstallJideExtension(int)
method. This style is the same as EXTENSION_STYLE_ECLIPSE 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. -
EXTENSION_STYLE_ECLIPSE3X_WITHOUT_MENU
public static final int EXTENSION_STYLE_ECLIPSE3X_WITHOUT_MENUA style that you can use withinstallJideExtension(int)
method. This style is the same as EXTENSION_STYLE_ECLIPSE3X 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. -
JIDE_EXTENSION_INSTALLED
If installJideExtension is called, it will put an entry on UIDefaults table. UIManagerLookup.getBoolean(JIDE_EXTENSION_INSTALLLED) will return true. You can also useisJideExtensionInstalled()
to check the value instead of using UIManagerLookup.getBoolean(JIDE_EXTENSION_INSTALLLED).- See Also:
-
JIDE_STYLE_INSTALLED
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.- See Also:
-
LAF_INSTALLED
- See Also:
-
LAF_NOT_INSTALLED
- See Also:
-
-
Constructor Details
-
LookAndFeelFactory
protected LookAndFeelFactory()
-
-
Method Details
-
getDefaultStyle
public static int getDefaultStyle()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.- Returns:
- the default style.
-
setDefaultStyle
public static void setDefaultStyle(int defaultStyle) Sets the default style. If you call this method to set a default style,installJideExtension()
will use it as the default style.- Parameters:
defaultStyle
- the default style.
-
installJideExtension
public static void installJideExtension()Adds additional UIDefaults JIDE needed to UIDefault table. You must call this method every time 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 additional 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) Add additional UIDefaults JIDE needed to UIDefaults table. You must call this method every time 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 additional UIDefault for JIDE components LookAndFeelFactory.installJideExtension(LookAndFeelFactory.OFFICE2003_STYLE); // call updateComponentTreeUI frame.getDockableBarManager().updateComponentTreeUI(); frame.getDockingManager().updateComponentTreeUI();
- Parameters:
style
- the style of the extension.
-
isJideExtensionInstalled
public static boolean isJideExtensionInstalled()Checks if JIDE extension is installed. Please note, UIManager.setLookAndFeel() method will overwrite the whole UIDefaults table. So even you calledinstallJideExtension()
method before, UIManager.setLookAndFeel() method make isJideExtensionInstalled returning false.- Returns:
- true if installed.
-
installJideExtension
Installs the UIDefault needed by JIDE component to the uiDefaults table passed in.- Parameters:
uiDefaults
- the UIDefault tables where JIDE UIDefaults will be installed.lnf
- the LookAndFeel. This may have an effect on which set of JIDE UIDefaults we will install.style
- the style of the JIDE UIDefaults.
-
registerDefaultInitializer
Registers a UIDefaultsInitializer with a L&F. Note that you can only register one initializer for a L&F.- Parameters:
lnfClassName
- full class name of the L&FinitializerClassName
- full class name of the UIDefaultInitializer
-
unregisterDefaultInitializer
Unregisters a UIDefaultsInitializer for L&F.- Parameters:
lnfClassName
- full class name of the L&F
-
clearDefaultInitializers
public static void clearDefaultInitializers()Clears all registered initializers. -
registerDefaultCustomizer
Registers a UIDefaultsCustomizer with a L&F. Note that you can only register one customizer for a L&F.- Parameters:
lnfClassName
- full class name of the L&FcustomizerClassName
- full class name of the UIDefaultsCustomizer
-
unregisterDefaultCustomizer
Unregisters a UIDefaultCustomizer for L&F.- Parameters:
lnfClassName
- full class name of the L&F
-
clearDefaultCustomizers
public static void clearDefaultCustomizers()Clears all registered customizers. -
isLnfInstalled
Returns whether or not the L&F is in classpath. This method will check for pre-installed L&Fs usingsetLnfInstalled(String, boolean)
. If the L&F is not pre-installed, we will try to use class loader to load the class to determine if the L&F is installed. If you don't want us to load the class, you can callsetLoadLookAndFeelClass(boolean)
false. If so, we will solely depend on the setLnfInstalled method to determine if the L&F is installed.- Parameters:
lnfName
- the L&F name.- Returns:
- true if the L&F is in classpath, false otherwise
-
getUIManagerClassLoader
-
isLnfInUse
Checks if the L&F is the L&F or a subclass of the L&F.- Parameters:
lnf
- the full class name of the L&F (including the package).- Returns:
- true or false.
-
setLnfInstalled
Tells the LookAndFeelFactory whether a L&F is installed. We will try to instantiate the class whenisLnfInstalled(String)
is called to determine if the class is in the class path. However you can call this method to tell if the L&F is available without us instantiating the class.- Parameters:
lnfName
- the L&F name.installed
- true or false.
-
isAquaLnfInstalled
public static boolean isAquaLnfInstalled()Returns whether or not the Aqua L&F is in classpath.- Returns:
- true if aqua L&F is in classpath, false otherwise
-
isQuaquaLnfInstalled
public static boolean isQuaquaLnfInstalled()Returns whether or not the Quaqua L&F is in classpath.- Returns:
- true if Quaqua L&F is in classpath, false otherwise
-
isAlloyLnfInstalled
public static boolean isAlloyLnfInstalled()Returns whether alloy L&F is in classpath- Returns:
- true alloy L&F is in classpath, false otherwise
-
isBizlafLnfInstalled
public static boolean isBizlafLnfInstalled()Returns whether Bizlaf L&F is in classpath- Returns:
- true Bizlaf L&F is in classpath, false otherwise
-
isGTKLnfInstalled
public static boolean isGTKLnfInstalled()Returns whether GTK L&F is in classpath- Returns:
- true GTK L&F is in classpath, false otherwise
-
isPlastic3DLnfInstalled
public static boolean isPlastic3DLnfInstalled()Returns whether Plastic3D L&F is in classpath- Returns:
- true Plastic3D L&F is in classpath, false otherwise
-
isPlastic3D13LnfInstalled
Deprecated.replace byisPlastic3DLnfInstalled()
Returns whether Plastic3D L&F is in classpath- Returns:
- true Plastic3D L&F is in classpath, false otherwise
-
isPlasticXPLnfInstalled
public static boolean isPlasticXPLnfInstalled()Returns whether PlasticXP L&F is in classpath- Returns:
- true Plastic3D L&F is in classpath, false otherwise
-
isTonicLnfInstalled
public static boolean isTonicLnfInstalled()Returns whether Tonic L&F is in classpath- Returns:
- true Tonic L&F is in classpath, false otherwise
-
isA03LnfInstalled
public static boolean isA03LnfInstalled()Returns whether A03 L&F is in classpath- Returns:
- true A03 L&F is in classpath, false otherwise
-
isDarculaLnfInstalled
public static boolean isDarculaLnfInstalled()Returns whether Darcula L&F is in classpath- Returns:
- true Darcula L&F is in classpath, false otherwise
-
isPgsLnfInstalled
public static boolean isPgsLnfInstalled()Returns whether or not the Pgs L&F is in classpath.- Returns:
- true if pgs L&F is in classpath, false otherwise
-
isSyntheticaLnfInstalled
public static boolean isSyntheticaLnfInstalled()Returns whether or not the Synthetica L&F is in classpath.- Returns:
- true if Synthetica L&F is in classpath, false otherwise
-
isNimbusLnfInstalled
public static boolean isNimbusLnfInstalled()Returns whether or not the Nimbus L&F is in classpath.- Returns:
- true if Nimbus L&F is in classpath, false otherwise
-
installDefaultLookAndFeelAndExtension
public static void installDefaultLookAndFeelAndExtension()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. -
installDefaultLookAndFeel
public static void installDefaultLookAndFeel()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. -
getLookAndFeel
Gets current L&F.- Returns:
- the current L&F.
-
getStyle
public static int getStyle()Gets current style.- Returns:
- the current style.
-
getUIDefaultsCustomizers
Gets all UIDefaults customizers.- Returns:
- an array of UIDefaults customizers.
-
addUIDefaultsCustomizer
public static void addUIDefaultsCustomizer(LookAndFeelFactory.UIDefaultsCustomizer uiDefaultsCustomizer) Adds your own UIDefaults customizer. You need to add it before installJideExtension() is called but the actual customize() code 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); } }); LookAndFeelFactory.installJideExtension();
- Parameters:
uiDefaultsCustomizer
- the UIDefaultsCustomizer
-
removeUIDefaultsCustomizer
public static void removeUIDefaultsCustomizer(LookAndFeelFactory.UIDefaultsCustomizer uiDefaultsCustomizer) Removes an existing UIDefaults customizer you added before.- Parameters:
uiDefaultsCustomizer
- the UIDefaultsCustomizer
-
getUIDefaultsInitializers
Gets all UIDefaults initializers.- Returns:
- an array of UIDefaults initializers.
-
addUIDefaultsInitializer
public static void addUIDefaultsInitializer(LookAndFeelFactory.UIDefaultsInitializer uiDefaultsInitializer) 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 callLookAndFeelFactory.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.
-
removeUIDefaultsInitializer
public static void removeUIDefaultsInitializer(LookAndFeelFactory.UIDefaultsInitializer uiDefaultsInitializer) Removes an existing UIDefaults initializer you added before.- Parameters:
uiDefaultsInitializer
- the UIDefaultsInitializer
-
verifyDefaults
-
putDefaults
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 fromputDefaults(javax.swing.UIDefaults, Object[])
method. You should use this method inLookAndFeelFactory.UIDefaultsInitializer
so that it fills in the UIDefault value only when it is missing.- Parameters:
table
- the ui defaults tablekeyValueArray
- the key value array. It is in the format of a key followed by a value.
-
overwriteDefaults
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 fromputDefaults(javax.swing.UIDefaults, Object[])
method. You should use this method inLookAndFeelFactory.UIDefaultsCustomizer
because you always want to override the existing value using the new value.- Parameters:
table
- the ui defaults tablekeyValueArray
- the key value array. It is in the format of a key followed by a value.
-
getProductsUsed
public static int getProductsUsed() -
isWindowsLookAndFeel
As of Java 10, com.sun.java.swing.plaf.windows.WindowsLookAndFeel is no longer available on macOS thus "instanceof WindowsLookAndFeel" directives will result in a NoClassDefFoundError during runtime. This method was introduced to avoid this exception.- Parameters:
lnf
-- Returns:
- true if it is a WindowsLookAndFeel.
-
isWindowsClassicLookAndFeel
As of Java 10, com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel is no longer available on macOS thus "instanceof WindowsClassicLookAndFeel" directives will result in a NoClassDefFoundError during runtime. This method was introduced to avoid this exception.- Parameters:
lnf
-- Returns:
- true if it is a WindowsClassicLookAndFeel.
-
setProductsUsed
public static void setProductsUsed(int productsUsed) 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 callsetProductUsed(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 callsetProductUsed(ProductNames.PRODUCT_COMMON)
. If you want to use all JIDE products, you should callsetProductUsed(ProductNames.PRODUCT_ALL)
- Parameters:
productsUsed
- a bit-wise OR of product values defined inProductNames
.
-
isCurrentLnfDecorated
public static boolean isCurrentLnfDecorated()Checks if the current L&F uses decorated frames.- Returns:
- true if the current L&F uses decorated frames. Otherwise false.
-
isLoadLookAndFeelClass
public static boolean isLoadLookAndFeelClass()Gets the flag indicating if JIDE will try to load the LnF class whenisLnfInstalled(String)
is invoked.- Returns:
- true if JIDE will try to load the LnF class. Otherwise false
- Since:
- 3.2.0
- See Also:
-
setLoadLookAndFeelClass
public static void setLoadLookAndFeelClass(boolean loadLookAndFeelClass) Sets the flag indicating if JIDE will try to load the L&F class whenisLnfInstalled(String)
is invoked. By default, this flag is true. However, it may cause unexpected class loading, which may be a performance issue for web start applications. If this is a concern to your application, please try to set this flag to false and invokesetLnfInstalled(String, boolean)
to makeisLnfInstalled(String)
returns correct value as you wish.- Parameters:
loadLookAndFeelClass
- the flag- Since:
- 3.2.0
-
isMnemonicHidden
public static boolean isMnemonicHidden() -
main
-