kiwi.ui
Class UIChangeManager

java.lang.Object
  |
  +--kiwi.ui.UIChangeManager

public final class UIChangeManager
extends 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.

Version:
1.0 (11/98)
Author:
Mark Lindner, PING Software Group

Field Summary
static String BUTTON_OPACITY_PROPERTY
          Button opacity property.
static String TEXTURE_PROPERTY
          Default texture property.
 
Method Summary
 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 getDefaultTexture()
          Get the default texture used for tiling the backgrounds of KPanels.
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 setDefaultTexture(Image texture)
          Set the default texture used for tiling backgrounds of KPanels.
 void unregisterComponent(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

BUTTON_OPACITY_PROPERTY

public static final String BUTTON_OPACITY_PROPERTY
Button opacity property.

TEXTURE_PROPERTY

public static final String TEXTURE_PROPERTY
Default texture property.
Method Detail

getInstance

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

addPropertyChangeListener

public void addPropertyChangeListener(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(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(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(JComponent c)
Unregister a component from the manager.
Parameters:
c - The component to unregister.
See Also:
registerComponent(javax.swing.JComponent)

changeLookAndFeel

public void changeLookAndFeel(LookAndFeel lf)
                       throws 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:
UnsupportedLookAndFeelException - If the specified Look & Feel is not available.

changeLookAndFeel

public void changeLookAndFeel(String className)
                       throws UnsupportedLookAndFeelException,
                              IllegalAccessException,
                              InstantiationException,
                              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:
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.

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 Image getDefaultTexture()
Get the default texture used for tiling the backgrounds of KPanels.
Returns:
The current texture.
See Also:
setDefaultTexture(java.awt.Image), KPanel

setDefaultTexture

public static void setDefaultTexture(Image texture)
Set the default texture used for tiling backgrounds of KPanels.
Parameters:
texture - The new texture.
See Also:
getDefaultTexture(), KPanel