ehsbe CommonsTM
Version 1.1.0rc3

com.ehsbe.commons.gui
Class LnF

java.lang.Object
  extended by com.ehsbe.commons.gui.LnF

public class LnF
extends Object

Look and Feel setting utils.

Version:
$Revision: 433 $
Author:
Jens Elkner

Field Summary
static String LNF_ACTION_PREFIX
          The ID aka action command prefix to be used for an action, which refers to a special Look and feel.
static String LNF_MENU_LIST
          the ID, that will be as ID the look and feel action list
static String LNF_NAME
          the name of the action property, which will contain the name of the requested Look and Feel
static String LNF_SUBLIST_PREFIX
          The ID aka action command prefix, which will be used for actions, which mark a sublist aka category of Look and Feels.
static String LNF_THEME
          the name of the action property, which will contain the requested name of the theme of the appropriate Look and Feel.
static String PREF_LNF
          user preference key for look and feel
static String PREF_LNF_DEFAULT
          user preference default value for look and feel
static String PREF_THEME
          user preference key for look and feel theme
static String PREF_THEME_DEFAULT
          user preference default value for look and feel theme
 
Constructor Summary
LnF()
           
 
Method Summary
static void createActions(HashMap<String,Action> actionMap, HashMap<String,List<Object>> actionLists)
          Create a action for each available Look and Feel [Theme] with an ID of "LNF_ACTION_" + N and put them into an action list with the ID "L_LNF_MENU" , which might be used to create a JMenu from it.
static String[] getLnfNames()
          Get all registered LNF names
static Color getSeparatorForeground()
          Get the default foreground color for separators.
static JLabel getSeparatorLabel(JComponent sep)
          Find and return the first JLabel in the given separator component (usually created by the jgoddies FormLayoutBuilder#addSeparator).
static String[] getThemes4Lnf(String lnf)
          Get all registered theme names for the given look and feel name.
static void main(String[] args)
           
static void saveAppLookAndFeel(Preferences prefs, Action action)
          Convinience method to store the given look and feel as well as the theme name in the given preferences obtained fro the given action.
static void saveAppLookAndFeel(Preferences prefs, String lnfName, String themeName)
          Convinience method to store the given look and feel as well as the theme name in the given preferences.
static void setAppLookAndFeel(Action action)
          Sets the application look and feel.
static void setAppLookAndFeel(Preferences prefs)
          Set the look and feel using the given preferences.
static void setAppLookAndFeel(String lnfName, String theme)
          Sets the application look and feel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREF_LNF

public static final String PREF_LNF
user preference key for look and feel

See Also:
Constant Field Values

PREF_LNF_DEFAULT

public static final String PREF_LNF_DEFAULT
user preference default value for look and feel

See Also:
Constant Field Values

PREF_THEME

public static final String PREF_THEME
user preference key for look and feel theme

See Also:
Constant Field Values

PREF_THEME_DEFAULT

public static final String PREF_THEME_DEFAULT
user preference default value for look and feel theme


LNF_MENU_LIST

public static final String LNF_MENU_LIST
the ID, that will be as ID the look and feel action list

See Also:
Constant Field Values

LNF_ACTION_PREFIX

public static final String LNF_ACTION_PREFIX
The ID aka action command prefix to be used for an action, which refers to a special Look and feel. This is the only action, where a listener should take the appropriate steps, to change the Look and Feel.

See Also:
Constant Field Values

LNF_SUBLIST_PREFIX

public static final String LNF_SUBLIST_PREFIX
The ID aka action command prefix, which will be used for actions, which mark a sublist aka category of Look and Feels.

See Also:
Constant Field Values

LNF_NAME

public static final String LNF_NAME
the name of the action property, which will contain the name of the requested Look and Feel

See Also:
Constant Field Values

LNF_THEME

public static final String LNF_THEME
the name of the action property, which will contain the requested name of the theme of the appropriate Look and Feel.

See Also:
Constant Field Values
Constructor Detail

LnF

public LnF()
Method Detail

getLnfNames

public static String[] getLnfNames()
Get all registered LNF names

Returns:
an array, which might be empty

getThemes4Lnf

public static String[] getThemes4Lnf(String lnf)
Get all registered theme names for the given look and feel name.

Parameters:
lnf - a look and feel name
Returns:
an array, which might be empty, but not null
See Also:
getLnfNames()

createActions

public static void createActions(HashMap<String,Action> actionMap,
                                 HashMap<String,List<Object>> actionLists)
Create a action for each available Look and Feel [Theme] with an ID of "LNF_ACTION_" + N and put them into an action list with the ID "L_LNF_MENU" , which might be used to create a JMenu from it.

Parameters:
actionMap - where to put the actions for each theme
actionLists - where to put the created action list
See Also:
LNF_ACTION_PREFIX, LNF_MENU_LIST

saveAppLookAndFeel

public static void saveAppLookAndFeel(Preferences prefs,
                                      Action action)
Convinience method to store the given look and feel as well as the theme name in the given preferences obtained fro the given action.

Parameters:
prefs - where to store the given values.
action - where to obtain the look and feel name and theme name. If null, this method does nothing. NOTE: If the action does not contain the appropriate properties, the look and feel settings will be removed from the given preferences.
See Also:
LNF_NAME, LNF_THEME, Action.getValue(String), saveAppLookAndFeel(Preferences, String, String), setAppLookAndFeel(Preferences)

saveAppLookAndFeel

public static void saveAppLookAndFeel(Preferences prefs,
                                      String lnfName,
                                      String themeName)
Convinience method to store the given look and feel as well as the theme name in the given preferences. If a name is null, the appropriate property will be removed from the preferences.

Parameters:
prefs - where to store the given values. If null, this method does nothing.
lnfName - the name of the look and feel to store
themeName - the name of the theme to store.

setAppLookAndFeel

public static void setAppLookAndFeel(Preferences prefs)
Set the look and feel using the given preferences.

Parameters:
prefs - preferences to use to obtain the appropriate Look and Feel name and the name of the theme. Ignored if null.
See Also:
setAppLookAndFeel(String, String)

setAppLookAndFeel

public static void setAppLookAndFeel(Action action)
Sets the application look and feel.

Parameters:
action - the action to query for the new Look and Feel name and theme name using the appropriate LNF properties keys.
See Also:
LNF_NAME, LNF_THEME, Action.getValue(String), setAppLookAndFeel(String, String)

setAppLookAndFeel

public static void setAppLookAndFeel(String lnfName,
                                     String theme)
Sets the application look and feel.

Parameters:
lnfName - the name of the Look and Feel to use.
theme - the name of the theme to use.
See Also:
getLnfNames(), getThemes4Lnf(String)

getSeparatorForeground

public static Color getSeparatorForeground()
Get the default foreground color for separators.

Returns:
the default foreground color for separators.

getSeparatorLabel

public static JLabel getSeparatorLabel(JComponent sep)
Find and return the first JLabel in the given separator component (usually created by the jgoddies FormLayoutBuilder#addSeparator).

Parameters:
sep - component to scan for a JLabel
Returns:
null if no JLabel was found, the first available JLabel otherwise.

main

public static void main(String[] args)
Parameters:
args -

ehsbe CommonsTM
Version 1.1.0rc3

Copyright ©2005-2009 EHSBE, Walther-Rathenau-Str. 58, 39104 Magdeburg, Sachsen-Anhalt, Germany. All Rights Reserved.