com.sun.jaf.ui
Class UIFactory

java.lang.Object
  |
  +--com.sun.jaf.ui.UIFactory

public class UIFactory
extends Object

Creates user interface elements based on action-lists managed in an ActionManagaer.

See Also:
ActionManager

Method Summary
protected  void configureButton(AbstractButton button, Action action)
          This method will be called after buttons created from an action.
protected static void configureMenuItem(JMenuItem menuItem, Action action)
          This method will be called after menu items are created.
protected  void configureToggleButton(JToggleButton button, Action action)
          This method will be called after toggle buttons are created.
protected static void configureToggleMenuItem(JMenuItem menuItem, Action action)
          This method will be called after toggle type menu items (like JRadioButtonMenuItem and JCheckBoxMenuItem) are created.
 JMenu createMenu(Object id)
          Creates and returns a menu from an action-list id.
 JMenuBar createMenuBar(Object id)
          Constructs a menu tree from an action-list id.
 JPopupMenu createPopup(Object id)
          Constructs a popup menu from an action-list id.
 JToolBar createToolBar(Object id)
          Constructs a toolbar from an action-list id.
static com.sun.jaf.ui.ActionManager getActionManager()
          Gets the ActionManager instance.
static com.sun.jaf.ui.UIFactory getInstance()
          Return the instance of the UIFactory if this will be used as a singleton.
static void setActionManager(com.sun.jaf.ui.ActionManager manager)
          Sets the ActionManager instance that will be used by this UIFactory
static void setInstance(com.sun.jaf.ui.UIFactory factory)
          Sets the UIFactory instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static com.sun.jaf.ui.UIFactory getInstance()
Return the instance of the UIFactory if this will be used as a singleton. The instance will be created if it hasn't previously been set.

Returns:
the UIFactory instance.
See Also:
setInstance(com.sun.jaf.ui.UIFactory)

setInstance

public static void setInstance(com.sun.jaf.ui.UIFactory factory)
Sets the UIFactory instance.


getActionManager

public static com.sun.jaf.ui.ActionManager getActionManager()
Gets the ActionManager instance. If the ActionManager has not been explicitly set then the default ActionManager instance will be used.

Returns:
the ActionManager used by the UIFactory.
See Also:
setActionManager(com.sun.jaf.ui.ActionManager)

setActionManager

public static void setActionManager(com.sun.jaf.ui.ActionManager manager)
Sets the ActionManager instance that will be used by this UIFactory


createToolBar

public JToolBar createToolBar(Object id)
Constructs a toolbar from an action-list id. By convention, the identifier of the main toolbar should be "main-toolbar"

Parameters:
id - action-list id which should be used to construct the toolbar.
Returns:
the toolbar or null

createPopup

public JPopupMenu createPopup(Object id)
Constructs a popup menu from an action-list id.

Parameters:
id - action-list id which should be used to construct the popup.
Returns:
the popup or null

createMenuBar

public JMenuBar createMenuBar(Object id)
Constructs a menu tree from an action-list id. The elements of the action-list will represent menus. By convention, the top level menu bar action-list id should be "main-menu"

Parameters:
id - the action-list id which represents the root item
Returns:
a menu bar which represents the xml tree or null if the tree cannot be found.

createMenu

public JMenu createMenu(Object id)
Creates and returns a menu from an action-list id. The menu constructed will have the attributes from the action id the ActionList.

Parameters:
id - the action-list id that may represents a menu.
Returns:
the constructed JMenu or null if an action-list cannot be found.

configureToggleButton

protected void configureToggleButton(JToggleButton button,
                                     Action action)
This method will be called after toggle buttons are created. Override for custom configuration but the overriden method should be called first.

Parameters:
button - the button to be configured
action - the action used to construct the menu item.

configureButton

protected void configureButton(AbstractButton button,
                               Action action)
This method will be called after buttons created from an action. Override for custom configuration.

Parameters:
button - the button to be configured
action - the action used to construct the menu item.

configureToggleMenuItem

protected static void configureToggleMenuItem(JMenuItem menuItem,
                                              Action action)
This method will be called after toggle type menu items (like JRadioButtonMenuItem and JCheckBoxMenuItem) are created. Override for custom configuration but the overriden method should be called first.

Parameters:
menuItem - the menu item to be configured
action - the action used to construct the menu item.

configureMenuItem

protected static void configureMenuItem(JMenuItem menuItem,
                                        Action action)
This method will be called after menu items are created. Override for custom configuration.

Parameters:
menuItem - the menu item to be configured
action - the action used to construct the menu item.