org.softsmithy.lib.swing.action
Class XActions

java.lang.Object
  extended by org.softsmithy.lib.swing.action.XActions

public class XActions
extends Object

A utility class for XActions.
Note: The API may change in a future version!

Author:
Florian Brunner
See Also:
XAction

Method Summary
static void configureButton(AbstractButton button, XAction action, ButtonGroup group, IconType iconType, boolean showText, boolean coolStyle)
          Configures a button from a XAction.
static void configureButton(AbstractButton button, XAction action, IconType iconType, boolean showText, boolean coolStyle)
          Configures a button from a XAction.
static void configureButton(AbstractButton button, XAction action, ItemListener listener, IconType iconType, boolean showText, boolean coolStyle)
          Configures a button from a XAction.
static void configureXAction(XAction action, String name, ResourceBundle rb)
          Configures an XAction from a ResourceBundle.
static JButton createButton(XAction action, IconType iconType, boolean showText, boolean coolStyle)
          Creates a configured button.
static JCheckBox createCheckBox(XAction action, ItemListener listener, IconType iconType, boolean showText)
          Creates a configured check box.
static JCheckBoxMenuItem createCheckBoxMenuItem(XAction action, ItemListener listener, IconType iconType, boolean showText)
          Creates a configured check button menu item.
static JMenu createEditMenu(Locale locale)
          Creates an edit menu with a localized text.
static JMenu createFileMenu(Locale locale)
          Creates a file menu with a localized text.
static JMenu createHelpMenu(Locale locale)
          Creates a help menu with a localized text.
static JMenuItem createMenuItem(XAction action, IconType iconType, boolean showText)
          Creates a configured menu item.
static JRadioButton createRadioButton(XAction action, ButtonGroup group, IconType iconType, boolean showText)
          Creates a configured radio button.
static JRadioButtonMenuItem createRadioButtonMenuItem(XAction action, ButtonGroup group, IconType iconType, boolean showText)
          Creates a configured radio button menu item.
static JToggleButton createToggleButton(XAction action, ButtonGroup group, IconType iconType, boolean showText, boolean coolStyle)
          Creates a configured toggle button.
static JToggleButton createToggleButton(XAction action, ItemListener listener, IconType iconType, boolean showText, boolean coolStyle)
          Creates a configured toggle button.
static XAction createXAction(String name, Object target, ResourceBundle rb)
          Creates a new XAction from a ResourceBundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createXAction

public static XAction createXAction(String name,
                                    Object target,
                                    ResourceBundle rb)
                             throws NoSuchMethodException
Creates a new XAction from a ResourceBundle.

Parameters:
name - the method name (must take an ActionEvent obect as its single parameter) that gets called when an ActionEvent occurs
target - the object with the specified method
rb - a ResourceBundle (doesn't have to specify all XAction properties)
Returns:
a XAction configured by a ResourceBundle
Throws:
NoSuchMethodException - if no such method found

configureXAction

public static void configureXAction(XAction action,
                                    String name,
                                    ResourceBundle rb)
Configures an XAction from a ResourceBundle. This method is looking for the following keys:

Key Value
<name>.name The name to be displayed
<name>.shortDescription Tool Tip
<name>.acceleratorKey Shortcut
<name>.mnemonicKey Mnemonic
<name>.largeDisabledIcon File Name
<name>.largeDisabledSelectedIcon File Name
<name>.largeIcon File Name
<name>.largePressedIcon File Name
<name>.largeRolloverIcon File Name
<name>.largeRolloverSelectedIcon File Name
<name>.largeSelectedIcon File Name
<name>.smallDisabledIcon File Name
<name>.smallDisabledSelectedIcon File Name
<name>.smallIcon File Name
<name>.smallPressedIcon File Name
<name>.smallRolloverIcon File Name
<name>.smallRolloverSelectedIcon File Name
<name>.smallSelectedIcon File Name

E.g.
myAction.name = MyAction
myAction.shortDescription = My Action
myAction.acceleratorKey = Control M
myAction.mnemonicKey = A
myAction.largeIcon = /myGraphics/MyAction24.gif
myAction.smallIcon = /myGraphics/MyAction16.gif

Parameters:
action - the XAction to configure
name - the base name of the keys
rb - a ResourceBundle (doesn't have to specify all XAction properties)

createButton

public static JButton createButton(XAction action,
                                   IconType iconType,
                                   boolean showText,
                                   boolean coolStyle)
Creates a configured button.

If cool style is set to true, then the border of the button will be drawn only if the mouse pointer is over the button. Note: Since Java 1.4 you can create a similar effect by setting the rollover property of the toolbar to true. However look and feels may ignore this property and the Java Look and Feel does so.

Parameters:
action - the XAction with the configuration data
iconType - the icon type
showText - if the label text should be shown
coolStyle - specifies if the cool style should be applied
Returns:
a configured button

createToggleButton

public static JToggleButton createToggleButton(XAction action,
                                               ItemListener listener,
                                               IconType iconType,
                                               boolean showText,
                                               boolean coolStyle)
Creates a configured toggle button.

If cool style is set to true, then the border of the button will be drawn only if the mouse pointer is over the button. Note: Since Java 1.4 you can create a similar effect by setting the rollover property of the toolbar to true. However look and feels may ignore this property and the Java Look and Feel does so.

Parameters:
action - the XAction with the configuration data
listener - a listener, which listens to the item state
iconType - the icon type
showText - if the label text should be shown
coolStyle - specifies if the cool style should be applied
Returns:
a configured toggle button

createToggleButton

public static JToggleButton createToggleButton(XAction action,
                                               ButtonGroup group,
                                               IconType iconType,
                                               boolean showText,
                                               boolean coolStyle)
Creates a configured toggle button.

If cool style is set to true, then the border of the button will be drawn only if the mouse pointer is over the button. Note: Since Java 1.4 you can create a similar effect by setting the rollover property of the toolbar to true. However look and feels may ignore this property and the Java Look and Feel does so.

Parameters:
action - the XAction with the configuration data
group - a ButtonGroup to which this button will be added
iconType - the icon type
showText - if the label text should be shown
coolStyle - specifies if the cool style should be applied
Returns:
a configured toggle button

createRadioButton

public static JRadioButton createRadioButton(XAction action,
                                             ButtonGroup group,
                                             IconType iconType,
                                             boolean showText)
Creates a configured radio button.

Parameters:
action - the XAction with the configuration data
group - a ButtonGroup to which this button will be added
iconType - the icon type
showText - if the label text should be shown
Returns:
a configured radio button

createCheckBox

public static JCheckBox createCheckBox(XAction action,
                                       ItemListener listener,
                                       IconType iconType,
                                       boolean showText)
Creates a configured check box.

Parameters:
action - the XAction with the configuration data
listener - a listener, which listens to the item state
iconType - the icon type
showText - if the label text should be shown
Returns:
a configured check box

createMenuItem

public static JMenuItem createMenuItem(XAction action,
                                       IconType iconType,
                                       boolean showText)
Creates a configured menu item.

Parameters:
action - the XAction with the configuration data
iconType - the icon type
showText - if the label text should be shown
Returns:
a configured menu item

createRadioButtonMenuItem

public static JRadioButtonMenuItem createRadioButtonMenuItem(XAction action,
                                                             ButtonGroup group,
                                                             IconType iconType,
                                                             boolean showText)
Creates a configured radio button menu item.

Parameters:
action - the XAction with the configuration data
group - a ButtonGroup to which this button will be added
iconType - the icon type
showText - if the label text should be shown
Returns:
a configured radio button menu item

createCheckBoxMenuItem

public static JCheckBoxMenuItem createCheckBoxMenuItem(XAction action,
                                                       ItemListener listener,
                                                       IconType iconType,
                                                       boolean showText)
Creates a configured check button menu item.

Parameters:
action - the XAction with the configuration data
listener - a listener, which listens to the item state
iconType - the icon type
showText - if the label text should be shown
Returns:
a configured check button menu item

configureButton

public static void configureButton(AbstractButton button,
                                   XAction action,
                                   ItemListener listener,
                                   IconType iconType,
                                   boolean showText,
                                   boolean coolStyle)
Configures a button from a XAction.

If cool style is set to true, then the border of the button will be drawn only if the mouse pointer is over the button. Note: Since Java 1.4 you can create a similar effect by setting the rollover property of the toolbar to true. However look and feels may ignore this property and the Java Look and Feel does so.

Parameters:
button - the button to configure
action - the XAction with the configuration data
listener - a listener, which listens to the item state
iconType - the icon type
showText - if the label text should be shown
coolStyle - specifies if the cool style should be applied

configureButton

public static void configureButton(AbstractButton button,
                                   XAction action,
                                   ButtonGroup group,
                                   IconType iconType,
                                   boolean showText,
                                   boolean coolStyle)
Configures a button from a XAction.

If cool style is set to true, then the border of the button will be drawn only if the mouse pointer is over the button. Note: Since Java 1.4 you can create a similar effect by setting the rollover property of the toolbar to true. However look and feels may ignore this property and the Java Look and Feel does so.

Parameters:
button - the button to configure
action - the XAction with the configuration data
group - a ButtonGroup to which this button will be added
iconType - the icon type
showText - if the label text should be shown
coolStyle - specifies if the cool style should be applied

configureButton

public static void configureButton(AbstractButton button,
                                   XAction action,
                                   IconType iconType,
                                   boolean showText,
                                   boolean coolStyle)
Configures a button from a XAction.

If cool style is set to true, then the border of the button will be drawn only if the mouse pointer is over the button. Note: Since Java 1.4 you can create a similar effect by setting the rollover property of the toolbar to true. However look and feels may ignore this property and the Java Look and Feel does so.

Parameters:
button - the button to configure
action - the XAction with the configuration data
iconType - the icon type
showText - if the label text should be shown
coolStyle - specifies if the cool style should be applied

createFileMenu

public static JMenu createFileMenu(Locale locale)
Creates a file menu with a localized text.

Parameters:
locale - the locale
Returns:
a file menu with a localized text

createEditMenu

public static JMenu createEditMenu(Locale locale)
Creates an edit menu with a localized text.

Parameters:
locale - the locale
Returns:
an edit menu with a localized text

createHelpMenu

public static JMenu createHelpMenu(Locale locale)
Creates a help menu with a localized text.

Parameters:
locale - the locale
Returns:
a help menu with a localized text


Copyright © 2002-2011 SoftSmithy. All Rights Reserved.