com.sun.lwuit.plaf
Class UIManager

java.lang.Object
  extended by com.sun.lwuit.plaf.UIManager

public class UIManager
extends java.lang.Object

Central point singleton managing the look of the application, this class allows us to customize the styles (themes) as well as the look instance.


Method Summary
 void addThemeProps(java.util.Hashtable themeProps)
          Adds the given theme properties on top of the existing properties without clearing the existing theme first
 void addThemeRefreshListener(ActionListener l)
          Adds a Theme refresh listener.
 Style getComponentCustomStyle(java.lang.String id, java.lang.String type)
          Returns a custom style for the component with the given id, this method always returns a new instance.
 Style getComponentSelectedStyle(java.lang.String id)
          Returns the selected style of the component with the given id or a new instance of the default style.
 Style getComponentStyle(java.lang.String id)
          Returns the style of the component with the given id or a new instance of the default style.
static UIManager getInstance()
          Singleton instance method
 LookAndFeel getLookAndFeel()
          Returns the currently installed look and feel
 java.util.Hashtable getResourceBundle()
          The resource bundle allows us to implicitly localize the UI on the fly, once its installed all internal application strings query the resource bundle and extract their values from this table if applicable.
 int getThemeConstant(java.lang.String constantName, int def)
          Returns a theme constant defined in the resource editor
 java.lang.String getThemeConstant(java.lang.String constantName, java.lang.String def)
          Returns a theme constant defined in the resource editor
 Image getThemeImageConstant(java.lang.String constantName)
          Returns a theme constant defined in the resource editor
 java.lang.String getThemeName()
           
 java.lang.Boolean isThemeConstant(java.lang.String constantName)
          Returns a theme constant defined in the resource editor as a boolean value or null if the constant isn't defined
 boolean isThemeConstant(java.lang.String constantName, boolean def)
          Returns a theme constant defined in the resource editor as a boolean value
 java.lang.String localize(java.lang.String key, java.lang.String defaultValue)
          Localizes the given string from the resource bundle if such a String exists in the resource bundle.
 void removeThemeRefreshListener(ActionListener l)
          Removes a Theme refresh listener.
 void setComponentSelectedStyle(java.lang.String id, Style style)
          Allows a developer to programmatically install a style into the UI manager
 void setComponentStyle(java.lang.String id, Style style)
          Allows a developer to programmatically install a style into the UI manager
 void setLookAndFeel(LookAndFeel plaf)
          Sets the currently installed look and feel
 void setResourceBundle(java.util.Hashtable resourceBundle)
          The resource bundle allows us to implicitly localize the UI on the fly, once its installed all internal application strings query the resource bundle and extract their values from this table if applicable.
 void setThemeProps(java.util.Hashtable themeProps)
          Allows manual theme loading from a hashtable of key/value pairs
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static UIManager getInstance()
Singleton instance method

Returns:
Instance of the ui manager

getLookAndFeel

public LookAndFeel getLookAndFeel()
Returns the currently installed look and feel

Returns:
the currently installed look and feel

setLookAndFeel

public void setLookAndFeel(LookAndFeel plaf)
Sets the currently installed look and feel

Parameters:
plaf - the look and feel for the application

setComponentStyle

public void setComponentStyle(java.lang.String id,
                              Style style)
Allows a developer to programmatically install a style into the UI manager

Parameters:
id - the component id matching the given style
style - the style object to install

setComponentSelectedStyle

public void setComponentSelectedStyle(java.lang.String id,
                                      Style style)
Allows a developer to programmatically install a style into the UI manager

Parameters:
id - the component id matching the given style
style - the style object to install

getComponentStyle

public Style getComponentStyle(java.lang.String id)
Returns the style of the component with the given id or a new instance of the default style. This method will always return a new style instance to prevent modification of the global style object.

Parameters:
id - the component id whose style we want
Returns:
the appropriate style (this method never returns null)

getComponentSelectedStyle

public Style getComponentSelectedStyle(java.lang.String id)
Returns the selected style of the component with the given id or a new instance of the default style. This method will always return a new style instance to prevent modification of the global style object.

Parameters:
id - the component id whose selected style we want
Returns:
the appropriate style (this method never returns null)

getComponentCustomStyle

public Style getComponentCustomStyle(java.lang.String id,
                                     java.lang.String type)
Returns a custom style for the component with the given id, this method always returns a new instance. Custom styles allow us to install application specific or component specific style attributes such as pressed, disabled, hover etc.

Parameters:
id - the component id whose custom style we want
type - the style type
Returns:
the appropriate style (this method never returns null)

getThemeName

public java.lang.String getThemeName()
Returns:
the name of the current theme for theme switching UI's

setThemeProps

public void setThemeProps(java.util.Hashtable themeProps)
Allows manual theme loading from a hashtable of key/value pairs

Parameters:
themeProps - the properties of the given theme

addThemeProps

public void addThemeProps(java.util.Hashtable themeProps)
Adds the given theme properties on top of the existing properties without clearing the existing theme first

Parameters:
themeProps - the properties of the given theme

getThemeConstant

public int getThemeConstant(java.lang.String constantName,
                            int def)
Returns a theme constant defined in the resource editor

Parameters:
constantName - the name of the constant
def - default value
Returns:
the value of the constant or the default if the constant isn't in the theme

getThemeConstant

public java.lang.String getThemeConstant(java.lang.String constantName,
                                         java.lang.String def)
Returns a theme constant defined in the resource editor

Parameters:
constantName - the name of the constant
def - default value
Returns:
the value of the constant or the default if the constant isn't in the theme

isThemeConstant

public boolean isThemeConstant(java.lang.String constantName,
                               boolean def)
Returns a theme constant defined in the resource editor as a boolean value

Parameters:
constantName - the name of the constant
def - default value
Returns:
the value of the constant or the default if the constant isn't in the theme

isThemeConstant

public java.lang.Boolean isThemeConstant(java.lang.String constantName)
Returns a theme constant defined in the resource editor as a boolean value or null if the constant isn't defined

Parameters:
constantName - the name of the constant
Returns:
the value of the constant or null if the constant isn't in the theme

getThemeImageConstant

public Image getThemeImageConstant(java.lang.String constantName)
Returns a theme constant defined in the resource editor

Parameters:
constantName - the name of the constant
Returns:
the image if defined

getResourceBundle

public java.util.Hashtable getResourceBundle()
The resource bundle allows us to implicitly localize the UI on the fly, once its installed all internal application strings query the resource bundle and extract their values from this table if applicable.

Returns:
the localization bundle

setResourceBundle

public void setResourceBundle(java.util.Hashtable resourceBundle)
The resource bundle allows us to implicitly localize the UI on the fly, once its installed all internal application strings query the resource bundle and extract their values from this table if applicable.

Parameters:
resourceBundle - the localization bundle

localize

public java.lang.String localize(java.lang.String key,
                                 java.lang.String defaultValue)
Localizes the given string from the resource bundle if such a String exists in the resource bundle. If no key exists in the bundle then or a bundle is not installed the default value is returned.

Parameters:
key - The key used to lookup in the resource bundle
defaultValue - the value returned if no such key exists
Returns:
either default value or the appropriate value

addThemeRefreshListener

public void addThemeRefreshListener(ActionListener l)
Adds a Theme refresh listener. The listenres will get a callback when setThemeProps method is invoked.

Parameters:
l - an ActionListener to be added

removeThemeRefreshListener

public void removeThemeRefreshListener(ActionListener l)
Removes a Theme refresh listener.

Parameters:
l - an ActionListener to be removed