public final class UIChangeManager extends Object implements PropertyChangeSource
UIChangeManager
manages
two lists of objects.
The first is a list of JFC components that need to be redrawn when the
application's Look & Feel changes. Generally only top-level components,
like descendants of JDialog
and JFrame
, need to
be registered, as the UIChangeManager
updates the Look & Feel
on the entire component hierarchy of each registered component.
The Kiwi KFrame
and KDialog
superclasses automatically register themselves with the change manager, so
any class that extends either of these will inherit this behavior.
The second is a list of classes that wish to be notified of other, more
fine-grained appearance changes that take place in the application: for
example, a change in the default background texture. Potentially hundreds
of components could be affected by a change in one of these appearance
properties, so it would be wasteful to register all of them for
notification by UIChangeManager
. The preferred alternative is
for each component to consult UIChangeManager
for the current
settings of the appropriate properties when it is constructing itself, so
that its appearance is in accordance with the current settings. Obviously,
only subsequently-created components will inherit appearance property
changes. For this reason, interface components that employ the singleton
pattern will need to register themselves as
PropertyChangeListener
s of UIChangeManager
and
redraw themselves when a property changes. DialogSet
is an
example of a class that implements this behavior.
Modifier and Type | Field and Description |
---|---|
static String |
BUTTON_OPACITY_PROPERTY
Button opacity property.
|
private static Vector |
components |
private static String |
DEFAULT_TEXTURE |
static String |
FRAME_ICON_PROPERTY |
private static UIChangeManager |
instance |
private static Vector |
listeners |
private static String |
METAL_PLAF |
private static Properties |
props |
private static PropertyChangeSupport |
support |
static String |
TEXTURE_PROPERTY
Default texture property.
|
Modifier | Constructor and Description |
---|---|
private |
UIChangeManager() |
Modifier and Type | Method and Description |
---|---|
private void |
_update() |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a
PropertyChangeListener to this object's list of
listeners. |
void |
changeLookAndFeel(LookAndFeel lf)
Change the Look & Feel globally.
|
void |
changeLookAndFeel(String className)
Change the Look & Feel globally.
|
static boolean |
getButtonsAreTransparent()
Get the state of the transparent buttons flag.
|
static Image |
getDefaultFrameIcon()
Get the default frame icon used for
KFrame s. |
static Image |
getDefaultTexture()
Get the default texture used for tiling the backgrounds of
KPanel s. |
static UIChangeManager |
getInstance()
Get a reference to the
UIChangeManager singleton. |
void |
registerComponent(JComponent c)
Register a component with the manager.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a
PropertyChangeListener from this object's list of
listeners. |
static void |
setButtonsAreTransparent(boolean flag)
Set the transparent buttons flag.
|
static void |
setColorTheme(ColorTheme theme)
Set the color theme.
|
static void |
setDefaultFrameIcon(Image icon)
Set the default frame icon to be used for
KFrame s. |
static void |
setDefaultTexture(Image texture)
Set the default texture used for tiling backgrounds of
KPanel s. |
void |
unregisterComponent(JComponent c)
Unregister a component from the manager.
|
private static UIChangeManager instance
private static Vector components
private static Properties props
private static PropertyChangeSupport support
public static final String BUTTON_OPACITY_PROPERTY
public static final String TEXTURE_PROPERTY
public static final String FRAME_ICON_PROPERTY
private static final String DEFAULT_TEXTURE
private static final String METAL_PLAF
private UIChangeManager()
public static UIChangeManager getInstance()
UIChangeManager
singleton.public void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
to this object's list of
listeners. Listeners are notified whenever a property of this object
is changed.addPropertyChangeListener
in interface PropertyChangeSource
listener
- The listener to add.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
from this object's list of
listeners.removePropertyChangeListener
in interface PropertyChangeSource
listener
- The listener to remove.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void registerComponent(JComponent c)
c
- The component to register.unregisterComponent(javax.swing.JComponent)
public void unregisterComponent(JComponent c)
c
- The component to unregister.registerComponent(javax.swing.JComponent)
public void changeLookAndFeel(LookAndFeel lf) throws UnsupportedLookAndFeelException
lf
- The new Look & Feel.UnsupportedLookAndFeelException
- If the specified Look & Feel
is not available.public void changeLookAndFeel(String className) throws UnsupportedLookAndFeelException, IllegalAccessException, InstantiationException, ClassNotFoundException
className
- The fully-qualified class name for the new Look & Feel.UnsupportedLookAndFeelException
- If the specified Look & Feel
is not available.IllegalAccessException
- If the specified class could not be
accessed.InstantiationException
- If the specified class could not be
instantiated.ClassNotFoundException
- If the specified class could not be
found.public static void setButtonsAreTransparent(boolean flag)
flag
- The new state of the flag; if true
,
KButton
s will be transparent by default.getButtonsAreTransparent()
,
KButton
public static boolean getButtonsAreTransparent()
setButtonsAreTransparent(boolean)
,
KButton
public static Image getDefaultTexture()
KPanel
s.null
if there is no default
texture.setDefaultTexture(java.awt.Image)
,
KPanel
public static void setDefaultTexture(Image texture)
KPanel
s.texture
- The new texture, or null
if no textures
should be used.getDefaultTexture()
,
KPanel
public static void setDefaultFrameIcon(Image icon)
KFrame
s.icon
- The new default frame icon, or null
if a
generic frame icon should be used.public static Image getDefaultFrameIcon()
KFrame
s.null
if there is no
default frame icon.public static void setColorTheme(ColorTheme theme)
theme
- The color theme.private void _update()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses