kiwi.ui
Class UIChangeManager

java.lang.Object
  extended bykiwi.ui.UIChangeManager
All Implemented Interfaces:
PropertyChangeSource

public final class UIChangeManager
extends java.lang.Object
implements PropertyChangeSource

This class functions as a clearinghouse for global appearance and look & feel changes for an application. 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 PropertyChangeListeners of UIChangeManager and redraw themselves when a property changes. DialogSet is an example of a class that implements this behavior.

Author:
Mark Lindner

Field Summary
static java.lang.String BUTTON_OPACITY_PROPERTY
          Button opacity property.
private static java.util.Vector components
           
private static java.lang.String DEFAULT_TEXTURE
           
static java.lang.String FRAME_ICON_PROPERTY
           
private static UIChangeManager instance
           
private static java.util.Vector listeners
           
private static java.lang.String METAL_PLAF
           
private static java.util.Properties props
           
private static java.beans.PropertyChangeSupport support
           
static java.lang.String TEXTURE_PROPERTY
          Default texture property.
 
Constructor Summary
private UIChangeManager()
           
 
Method Summary
private  void _update()
           
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener to this object's list of listeners.
 void changeLookAndFeel(javax.swing.LookAndFeel lf)
          Change the Look & Feel globally.
 void changeLookAndFeel(java.lang.String className)
          Change the Look & Feel globally.
static boolean getButtonsAreTransparent()
          Get the state of the transparent buttons flag.
static java.awt.Image getDefaultFrameIcon()
          Get the default frame icon used for KFrames.
static java.awt.Image getDefaultTexture()
          Get the default texture used for tiling the backgrounds of KPanels.
static UIChangeManager getInstance()
          Get a reference to the UIChangeManager singleton.
 void registerComponent(javax.swing.JComponent c)
          Register a component with the manager.
 void removePropertyChangeListener(java.beans.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(java.awt.Image icon)
          Set the default frame icon to be used for KFrames.
static void setDefaultTexture(java.awt.Image texture)
          Set the default texture used for tiling backgrounds of KPanels.
 void unregisterComponent(javax.swing.JComponent c)
          Unregister a component from the manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static UIChangeManager instance

components

private static java.util.Vector components

listeners

private static java.util.Vector listeners

props

private static java.util.Properties props

support

private static java.beans.PropertyChangeSupport support

BUTTON_OPACITY_PROPERTY

public static final java.lang.String BUTTON_OPACITY_PROPERTY
Button opacity property.

See Also:
Constant Field Values

TEXTURE_PROPERTY

public static final java.lang.String TEXTURE_PROPERTY
Default texture property.

See Also:
Constant Field Values

FRAME_ICON_PROPERTY

public static final java.lang.String FRAME_ICON_PROPERTY
See Also:
Constant Field Values

DEFAULT_TEXTURE

private static final java.lang.String DEFAULT_TEXTURE
See Also:
Constant Field Values

METAL_PLAF

private static final java.lang.String METAL_PLAF
See Also:
Constant Field Values
Constructor Detail

UIChangeManager

private UIChangeManager()
Method Detail

getInstance

public static UIChangeManager getInstance()
Get a reference to the UIChangeManager singleton.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to this object's list of listeners. Listeners are notified whenever a property of this object is changed.

Specified by:
addPropertyChangeListener in interface PropertyChangeSource
Parameters:
listener - The listener to add.
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from this object's list of listeners.

Specified by:
removePropertyChangeListener in interface PropertyChangeSource
Parameters:
listener - The listener to remove.
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)

registerComponent

public void registerComponent(javax.swing.JComponent c)
Register a component with the manager. If the given component is already registered, the method call has no effect. The registered component will have its UI updated whenever the Look & Feel of the application changes.

Parameters:
c - The component to register.
See Also:
unregisterComponent(javax.swing.JComponent)

unregisterComponent

public void unregisterComponent(javax.swing.JComponent c)
Unregister a component from the manager.

Parameters:
c - The component to unregister.
See Also:
registerComponent(javax.swing.JComponent)

changeLookAndFeel

public void changeLookAndFeel(javax.swing.LookAndFeel lf)
                       throws javax.swing.UnsupportedLookAndFeelException
Change the Look & Feel globally. Each registered component (and every child component thereof) will be updated to use the new Look & Feel.

Parameters:
lf - The new Look & Feel.
Throws:
javax.swing.UnsupportedLookAndFeelException - If the specified Look & Feel is not available.

changeLookAndFeel

public void changeLookAndFeel(java.lang.String className)
                       throws javax.swing.UnsupportedLookAndFeelException,
                              java.lang.IllegalAccessException,
                              java.lang.InstantiationException,
                              java.lang.ClassNotFoundException
Change the Look & Feel globally. Each registered component (and every child component thereof) will be updated to use the new Look & Feel.

Parameters:
className - The fully-qualified class name for the new Look & Feel.
Throws:
javax.swing.UnsupportedLookAndFeelException - If the specified Look & Feel is not available.
java.lang.IllegalAccessException - If the specified class could not be accessed.
java.lang.InstantiationException - If the specified class could not be instantiated.
java.lang.ClassNotFoundException - If the specified class could not be found.

setButtonsAreTransparent

public static void setButtonsAreTransparent(boolean flag)
Set the transparent buttons flag.

Parameters:
flag - The new state of the flag; if true, KButtons will be transparent by default.
See Also:
getButtonsAreTransparent(), KButton

getButtonsAreTransparent

public static boolean getButtonsAreTransparent()
Get the state of the transparent buttons flag.

Returns:
The current state of the flag.
See Also:
setButtonsAreTransparent(boolean), KButton

getDefaultTexture

public static java.awt.Image getDefaultTexture()
Get the default texture used for tiling the backgrounds of KPanels.

Returns:
The current texture, or null if there is no default texture.
See Also:
setDefaultTexture(java.awt.Image), KPanel

setDefaultTexture

public static void setDefaultTexture(java.awt.Image texture)
Set the default texture used for tiling backgrounds of KPanels.

Parameters:
texture - The new texture, or null if no textures should be used.
See Also:
getDefaultTexture(), KPanel

setDefaultFrameIcon

public static void setDefaultFrameIcon(java.awt.Image icon)
Set the default frame icon to be used for KFrames.

Parameters:
icon - The new default frame icon, or null if a generic frame icon should be used.
Since:
Kiwi 1.4.2

getDefaultFrameIcon

public static java.awt.Image getDefaultFrameIcon()
Get the default frame icon used for KFrames.

Returns:
The current frame icon, or null if there is no default frame icon.
Since:
Kiwi 1.4.2

setColorTheme

public static void setColorTheme(ColorTheme theme)
Set the color theme.

Parameters:
theme - The color theme.

_update

private void _update()