public abstract class LookAndFeelAddons extends Object
getBestMatchAddonClassName()
.
The default addon can be configured using the swing.addon
system property as follow:
java -Dswing.addon=ADDONCLASSNAME ...
System.getProperties().put("swing.addon", ADDONCLASSNAME);
The default cross platform addon
can be configured
using the swing.crossplatformlafaddon
system property as follow:
java -Dswing.crossplatformlafaddon=ADDONCLASSNAME ...
System.getProperties().put("swing.crossplatformlafaddon", ADDONCLASSNAME);
The addon can also be installed directly by calling the setAddon(String)
method. For
example, to install the Windows addons, add the following statement
LookAndFeelAddons.setAddon("org.jdesktop.swingx.plaf.windows.WindowsLookAndFeelAddons");
.
Modifier and Type | Class and Description |
---|---|
private static class |
LookAndFeelAddons.UpdateAddon |
Modifier and Type | Field and Description |
---|---|
private static Object |
APPCONTEXT_INITIALIZED
Key used to ensure the current UIManager has been populated by the LookAndFeelAddons.
|
private static PropertyChangeListener |
changeListener |
private static List<ComponentAddon> |
contributedComponents |
private static LookAndFeelAddons |
currentAddon |
private static boolean |
trackingChanges |
Constructor and Description |
---|
LookAndFeelAddons() |
Modifier and Type | Method and Description |
---|---|
private static void |
barkOnUIError(String message) |
static void |
contribute(ComponentAddon component)
Each new component added by the library will contribute its default UI classes, colors and
fonts to the LookAndFeelAddons.
|
static LookAndFeelAddons |
getAddon() |
static String |
getBestMatchAddonClassName()
Based on the current look and feel (as returned by
UIManager.getLookAndFeel() ),
this method returns the name of the closest LookAndFeelAddons to use. |
private static ClassLoader |
getClassLoader() |
static String |
getCrossPlatformAddonClassName() |
static String |
getSystemAddonClassName()
Gets the addon best suited for the operating system where the virtual machine is running.
|
static ComponentUI |
getUI(JComponent component,
Class<?> expectedUIClass)
Workaround for IDE mixing up with classloaders and Applets environments.
|
void |
initialize()
Initializes the look and feel addon.
|
static void |
installBackgroundPainter(JComponent c,
String painter)
Convenience method for setting a component's background painter property with a value from
the defaults.
|
protected boolean |
isSystemAddon()
Determines if the addon is a match for the system Look and Feel.
|
static boolean |
isTrackingLookAndFeelChanges() |
void |
loadDefaults(Object[] keysAndValues)
Adds the given defaults in UIManager.
|
protected boolean |
matches()
Determines if the addon is a match for the
current Look and
Feel . |
private static void |
maybeInitialize()
With applets, if you reload the current applet, the UIManager will be reinitialized (entries
previously added by LookAndFeelAddons will be removed) but the addon will not reinitialize
because addon initialize itself through the static block in components and the classes do not
get reloaded.
|
static void |
setAddon(Class<?> addonClass) |
static void |
setAddon(LookAndFeelAddons addon) |
static void |
setAddon(String addonClassName) |
static void |
setTrackingLookAndFeelChanges(boolean tracking)
If true, everytime the Swing look and feel is changed, the addon which best matches the
current look and feel will be automatically selected.
|
static void |
uncontribute(ComponentAddon component)
Removes the contribution of the given addon
|
void |
uninitialize() |
static void |
uninstallBackgroundPainter(JComponent c)
Convenience method for uninstalling a background painter.
|
void |
unloadDefaults(Object[] keysAndValues) |
private static List<ComponentAddon> contributedComponents
private static final Object APPCONTEXT_INITIALIZED
private static boolean trackingChanges
private static PropertyChangeListener changeListener
private static LookAndFeelAddons currentAddon
public LookAndFeelAddons()
protected boolean matches()
current Look and
Feel
.true
if this addon matches (is compatible); false
otherwiseprotected boolean isSystemAddon()
true
if this addon matches (is compatible with) the system Look and Feel;
false
otherwisepublic void initialize()
public void uninitialize()
public void loadDefaults(Object[] keysAndValues)
keysAndValues
- public void unloadDefaults(Object[] keysAndValues)
public static void setAddon(String addonClassName) throws InstantiationException, IllegalAccessException, ClassNotFoundException
public static void setAddon(Class<?> addonClass) throws InstantiationException, IllegalAccessException
public static void setAddon(LookAndFeelAddons addon)
public static LookAndFeelAddons getAddon()
private static ClassLoader getClassLoader()
public static String getBestMatchAddonClassName()
UIManager.getLookAndFeel()
),
this method returns the name of the closest LookAndFeelAddons
to use.public static String getCrossPlatformAddonClassName()
public static String getSystemAddonClassName()
public static void contribute(ComponentAddon component)
ComponentAddon
.component
- public static void uncontribute(ComponentAddon component)
component
- public static ComponentUI getUI(JComponent component, Class<?> expectedUIClass)
component
- expectedUIClass
- private static void barkOnUIError(String message)
private static void maybeInitialize()
public static void setTrackingLookAndFeelChanges(boolean tracking)
tracking
- true to automatically update the addon, false to not automatically track the
addon. Defaults to false.getBestMatchAddonClassName()
public static boolean isTrackingLookAndFeelChanges()
setTrackingLookAndFeelChanges(boolean)
public static void installBackgroundPainter(JComponent c, String painter)
null
or an instance of
UIResource
.c
- component to set the painter onpainter
- key specifying the painterNullPointerException
- if the component or painter is null
IllegalArgumentException
- if the component does not contain the "backgroundPainter" property or the
property cannot be setpublic static void uninstallBackgroundPainter(JComponent c)
UIResource
, it is set to null
.c
- component to uninstall the painter onNullPointerException
- if c
is null
IllegalArgumentException
- if the component does not contain the "backgroundPainter" property or the
property cannot be setWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses