Poseidon for UMLTM
  UMLdoc
 PREV  CLASSIFIER    NEXT  CLASSIFIER     FRAMES    NO FRAMES      
SUMMARY:   INNER | ATTR | ASSOC | CONSTR | METHOD     DETAIL:   INNER | ATTR | ASSOC | CONSTR | METHOD     DIAGRAMS:   COLLAB | SEQ | STATE | ACTIV

com.gentleware.services.swingx

Class SwingFactory

com.gentleware.services.swingx.SwingFactory

public class SwingFactory


SwingFactory provides factory methods for constructing swing components using values from resource bundles. All components created using these methods will automagically update whenever the locale changes.


 Attribute Summary
private static String  RESOURCE_ID_KEY
JComponents store their resource id as a client property using this key  
private static ActionListener  _buttonListener
 
private static Set  _labels
 
private static Localizer.Listener  _localeListener
Handle a change of the locale (language/country): Update all labels  
private static boolean  _staticInitDone
 
arrow_up
 

 Constructor Summary
public   SwingFactory()
SwingFactory is not meant to be instantiated. 
arrow_up
 

 Method Summary
public static void   configureAction(Action action, ResourceId resourceId)
Configure an action with data from a resource bundle. 
private static void   configureButton(AbstractButton button, ComponentResources resource)
Configure an abstract button subclass  
public static void   configureButton(AbstractButton button, Action action)
Configure an abstract button subclass  
private static void   configureLabel(JLabel label)
Configure a JLabel  
static int   findDisplayedMnemonicIndex(String text, Integer mnemonic)
Returns index of the first occurrence of mnemonic within string text
public static AbstractButton   makeButton(Action action)
Construct a new JButton. 
public static AbstractButton   makeButton(ResourceId resourceId)
 
public static JCheckBox   makeCheckBox(ResourceId resourceId)
 
public static JCheckBox   makeCheckBox(Action action)
Construct a new JCheckBox. 
public static JCheckBoxMenuItem   makeCheckBoxMenuItem(Action action)
 
public static Cursor   makeCursor(ResourceId resourceId)
 
public static Cursor   makeCursor(ResourceId resourceId, Cursor defaultCursor)
 
public static JButton   makeJButton(ResourceId resourceId)
Always creates a plain push button (ignores the toggle button flag from the properties file). 
public static JButton   makeJButton(Action action)
Always creates a plain push button (ignores the toggle button flag from the properties file). 
public static JLabel   makeLabel(ResourceId resourceId, JComponent labelForComponent)
Construct a new JLabel. 
public static JMenu   makeMenu(ResourceId resourceId)
Construct a new JMenu. 
public static JMenuItem   makeMenuItem(Action action)
Construct a new JMenuItem. 
public static JRadioButton   makeRadioButton(Action action)
 
public static JRadioButton   makeRadioButton(ResourceId resourceId)
 
public static JRadioButtonMenuItem   makeRadioButtonMenuItem(Action action)
 
public static AbstractButton   makeToolBarButton(Action action)
JToolBar.add(Action) creates a button and sets that buttons' "hideActionText" client property to true. 
public static AbstractButton   makeToolBarButton(ResourceId resourceId)
 
private static void   staticInit()
This could be done with a static initializer, but the SwingFactory class loading can occur very early and Services might not be initialized at that moment. 
arrow_up
 

Tagged Values
static false
 

 Attribute Detail

RESOURCE_ID_KEY

private static String RESOURCE_ID_KEY

JComponents store their resource id as a client property using this key  
arrow_up


_buttonListener

private static ActionListener _buttonListener

arrow_up


_labels

private static Set _labels

arrow_up


_localeListener

private static Localizer.Listener _localeListener

Handle a change of the locale (language/country): Update all labels  
arrow_up


_staticInitDone

private static boolean _staticInitDone

arrow_up
 Constructor Detail

SwingFactory

public SwingFactory SwingFactory()


SwingFactory is not meant to be instantiated. It has static methods only.  
Returns:
arrow_up
 Method Detail

configureAction

public static void configureAction(Action action, ResourceId resourceId)


Configure an action with data from a resource bundle. (Called from XAbstractAction's constructor and for each action whenever the locale is changed.)  
Parameters:
action -
resourceId -
arrow_up


configureButton

private static void configureButton(AbstractButton button, ComponentResources resource)


Configure an abstract button subclass  
Parameters:
button -
resource -
arrow_up


configureButton

public static void configureButton(AbstractButton button, Action action)


Configure an abstract button subclass  
Parameters:
button -
action -
arrow_up


configureLabel

private static void configureLabel(JLabel label)


Configure a JLabel  
Parameters:
label -
arrow_up


findDisplayedMnemonicIndex

static int findDisplayedMnemonicIndex(String text, Integer mnemonic)


Returns index of the first occurrence of mnemonic within string text. Matching algorithm is not case-sensitive. (Copied from SwingUtilities - is package private there.)  
Parameters:
text - The text to search through, may be null
mnemonic - The mnemonic to find the character for.
Returns:
index into the string if exists, otherwise -1
arrow_up


makeButton

public static AbstractButton makeButton(Action action)


Construct a new JButton. The button will have an associated XAbstractAction, so that when the locale changes the action will be configured again, and the button will automatically update.  
Parameters:
action -
Returns:
arrow_up


makeButton

public static AbstractButton makeButton(ResourceId resourceId)

Parameters:
resourceId -
Returns:
arrow_up


makeCheckBox

public static JCheckBox makeCheckBox(ResourceId resourceId)

Parameters:
resourceId -
Returns:
arrow_up


makeCheckBox

public static JCheckBox makeCheckBox(Action action)


Construct a new JCheckBox. The check box is associated to the given XAbstractAction, so that when the locale changes the action will be configured again, and the check box will automatically update.  
Parameters:
action -
Returns:
arrow_up


makeCheckBoxMenuItem

public static JCheckBoxMenuItem makeCheckBoxMenuItem(Action action)

Parameters:
action -
Returns:
arrow_up


makeCursor

public static Cursor makeCursor(ResourceId resourceId)

Parameters:
resourceId -
Returns:
arrow_up


makeCursor

public static Cursor makeCursor(ResourceId resourceId, Cursor defaultCursor)

Parameters:
resourceId -
defaultCursor -
Returns:
arrow_up


makeJButton

public static JButton makeJButton(ResourceId resourceId)


Always creates a plain push button (ignores the toggle button flag from the properties file).  
Parameters:
resourceId -
Returns:
arrow_up


makeJButton

public static JButton makeJButton(Action action)


Always creates a plain push button (ignores the toggle button flag from the properties file).  
Parameters:
action -
Returns:
arrow_up


makeLabel

public static JLabel makeLabel(ResourceId resourceId, JComponent labelForComponent)


Construct a new JLabel. The label instance is remembered in a (weak) collection and its properties are updated when the locale changes.  
Parameters:
resourceId -
labelForComponent -
Returns:
arrow_up


makeMenu

public static JMenu makeMenu(ResourceId resourceId)


Construct a new JMenu. The menu will have an associated XAbstractAction, so that when the locale changes the action will be configured again, and the menu will automatically update.  
Parameters:
resourceId -
Returns:
arrow_up


makeMenuItem

public static JMenuItem makeMenuItem(Action action)


Construct a new JMenuItem. The menu item will have an associated XAbstractAction, so that when the locale changes the action will be configured again, and the menu item will automatically update.  
Parameters:
action -
Returns:
arrow_up


makeRadioButton

public static JRadioButton makeRadioButton(Action action)

Parameters:
action -
Returns:
arrow_up


makeRadioButton

public static JRadioButton makeRadioButton(ResourceId resourceId)

Parameters:
resourceId -
Returns:
arrow_up


makeRadioButtonMenuItem

public static JRadioButtonMenuItem makeRadioButtonMenuItem(Action action)

Parameters:
action -
Returns:
arrow_up


makeToolBarButton

public static AbstractButton makeToolBarButton(Action action)


JToolBar.add(Action) creates a button and sets that buttons' "hideActionText" client property to true. Unfortunatly that add() method should not be used any longer (see javadoc) and we want to handle our XAbstractActions specially anyway. So use another client property to indicate that this should be a toolbar button and check for this property in configureButton(). Creates a button that is meant to be used in a toolbar: Text is only displayed if there's no icon. Mnemonic is always cleared.  
Parameters:
action -
Returns:
arrow_up


makeToolBarButton

public static AbstractButton makeToolBarButton(ResourceId resourceId)

Parameters:
resourceId -
Returns:
arrow_up


staticInit

private static void staticInit()


This could be done with a static initializer, but the SwingFactory class loading can occur very early and Services might not be initialized at that moment. So defer the access to Services until any method is called.  
arrow_up
Created  2004 - 10 - 21

    Poseidon for UMLTM
  UMLdoc
 PREV  CLASSIFIER    NEXT  CLASSIFIER     FRAMES    NO FRAMES      
SUMMARY:   INNER | ATTR | ASSOC | CONSTR | METHOD     DETAIL:   INNER | ATTR | ASSOC | CONSTR | METHOD     DIAGRAMS:   COLLAB | SEQ | STATE | ACTIV

Generated with Poseidon for UMLTM.
Poseidon is a registered trademark of Gentleware AG in Germany, USA and other countries. Copyright 2003-2004 Gentleware AG, Schanzenstr. 70, 20357 Hamburg, Germany. All Rights Reserved.

UML is a trademark or registered trademark of Object Management Group, Inc. in the U.S. and other countries.