com.cleancode.swing
Class JMenuItemSpec

java.lang.Object
  extended by com.cleancode.swing.JMenuItemSpec

public class JMenuItemSpec
extends Object

A specification for a JMenuItem used as a component of a JMenuSpec. The specification includes: a JMenuItem, an identifying action command, the keyboard mnemonic, the keyboard accelerator, the accelerator modifier key mask, and the enabled status of the menu item. The assorted constructors provide for omitting combinations of these parameters. The table below shows the values when omitted.

parameter required? default value method to change default
JMenuItem required NA NA
mnemonic key optional auto-assigned none
action command required NA NA
enabled status optional true setDefaultEnable
accelerator key optional NA none
accelerator modifier mask optional ActionEvent.CTRL_MASK setDefaultAccModifier


A JMenuBarMgr defines a menu bar consisting of JMenuSpec items. A JMenuSpec defines a menu consisting of JMenuItemSpec items.

Since:
CleanCode 0.9
Version:
$Revision: 9 $
Author:
Michael Sorens
See Also:
JMenuSpec, JMenuBarMgr

Field Summary
static String VERSION
          Current version of this class.
 
Constructor Summary
JMenuItemSpec()
          Creates a JMenuItemSpec which specifies a menu separator.
JMenuItemSpec(JMenuItem mItem, int mn, String cmd, boolean en)
          Creates a JMenuItemSpec without an accelerator key.
JMenuItemSpec(JMenuItem mItem, int mn, String cmd, boolean en, int acc)
          Creates a JMenuItemSpec where the accelerator modifier is determined by the default setting.
JMenuItemSpec(JMenuItem mItem, int mn, String cmd, boolean en, int acc, int accMod)
          Creates a fully-specified JMenuItemSpec object.
JMenuItemSpec(JMenuItem mItem, int mn, String cmd, int acc, int accMod)
          Creates a JMenuItemSpec where the initial enabled status is determined by the default setting.
JMenuItemSpec(JMenuItem mItem, String cmd)
          Creates a JMenuItemSpec without an accelerator key, where the initial enabled status is determined by the default setting, and the mnemonic is auto-assigned.
JMenuItemSpec(JMenuItem mItem, String cmd, boolean en)
          Creates a JMenuItemSpec where the mnemonic is auto-assigned and without an accelerator key.
JMenuItemSpec(JMenuItem mItem, String cmd, boolean en, int acc)
          Creates a JMenuItemSpec where the accelerator modifier is determined by the default setting and the mnemonic is auto-assigned.
JMenuItemSpec(JMenuItem mItem, String cmd, boolean en, int acc, int accMod)
          Creates a JMenuItemSpec where the mnemonic is auto-assigned.
JMenuItemSpec(JMenuItem mItem, String cmd, int acc)
          Creates a JMenuItemSpec where the initial enabled status and the accelerator modifier are determined by the default setting, and the mnemonic is auto-assigned.
JMenuItemSpec(JMenuItem mItem, String cmd, int acc, int accMod)
          Creates a JMenuItemSpec where the initial enabled status is determined by the default setting and the mnemonic is auto-assigned.
 
Method Summary
 void setDefaultAccModifier(int newDefaultAccModifier)
          Changes the default accelerator modifier used by the constructors which omit one.
 void setDefaultEnable(boolean enable)
          Changes the default enabled status used by the constructors which omit one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
Current version of this class.

Constructor Detail

JMenuItemSpec

public JMenuItemSpec(JMenuItem mItem,
                     int mn,
                     String cmd,
                     boolean en,
                     int acc,
                     int accMod)
Creates a fully-specified JMenuItemSpec object.

Parameters:
mItem - a JMenuItem object to which the remaining parameters apply
mn - a keyboard mnemonic (key which selects item when menu is open)
cmd - an action command for the menu item, used as an ID of the item
en - a boolean flag indicating whether the menu item is initially enabled
acc - a keyboard accelerator (key which selects item without an open menu)
accMod - a modifier key for the accelerator

JMenuItemSpec

public JMenuItemSpec(JMenuItem mItem,
                     int mn,
                     String cmd,
                     int acc,
                     int accMod)
Creates a JMenuItemSpec where the initial enabled status is determined by the default setting.

Parameters:
mItem - a JMenuItem object to which the remaining parameters apply
mn - a keyboard mnemonic (key which selects item when menu is open)
cmd - an action command for the menu item, used as an ID of the item
acc - a keyboard accelerator (key which selects item without an open menu)
accMod - a modifier key for the accelerator (CTRL, ALT, SHIFT, or none)

JMenuItemSpec

public JMenuItemSpec(JMenuItem mItem,
                     int mn,
                     String cmd,
                     boolean en,
                     int acc)
Creates a JMenuItemSpec where the accelerator modifier is determined by the default setting.

Parameters:
mItem - a JMenuItem object to which the remaining parameters apply
mn - a keyboard mnemonic (key which selects item when menu is open)
cmd - an action command for the menu item, used as an ID of the item
en - a boolean flag indicating whether the menu item is initially enabled
acc - a keyboard accelerator (key which selects item without an open menu)

JMenuItemSpec

public JMenuItemSpec(JMenuItem mItem,
                     String cmd,
                     boolean en,
                     int acc,
                     int accMod)
Creates a JMenuItemSpec where the mnemonic is auto-assigned.

Parameters:
mItem - a JMenuItem object to which the remaining parameters apply
cmd - an action command for the menu item, used as an ID of the item
en - a boolean flag indicating whether the menu item is initially enabled
acc - a keyboard accelerator (key which selects item without an open menu)
accMod - a modifier key for the accelerator (CTRL, ALT, SHIFT, or none)

JMenuItemSpec

public JMenuItemSpec(JMenuItem mItem,
                     int mn,
                     String cmd,
                     boolean en)
Creates a JMenuItemSpec without an accelerator key.

Parameters:
mItem - a JMenuItem object to which the remaining parameters apply
mn - a keyboard mnemonic (key which selects item when menu is open)
cmd - an action command for the menu item, used as an ID of the item
en - a boolean flag indicating whether the menu item is initially enabled

JMenuItemSpec

public JMenuItemSpec(JMenuItem mItem,
                     String cmd,
                     boolean en,
                     int acc)
Creates a JMenuItemSpec where the accelerator modifier is determined by the default setting and the mnemonic is auto-assigned.

Parameters:
mItem - a JMenuItem object to which the remaining parameters apply
cmd - an action command for the menu item, used as an ID of the item
en - a boolean flag indicating whether the menu item is initially enabled
acc - a keyboard accelerator (key which selects item without an open menu)

JMenuItemSpec

public JMenuItemSpec(JMenuItem mItem,
                     String cmd,
                     boolean en)
Creates a JMenuItemSpec where the mnemonic is auto-assigned and without an accelerator key.

Parameters:
mItem - a JMenuItem object to which the remaining parameters apply
cmd - an action command for the menu item, used as an ID of the item
en - a boolean flag indicating whether the menu item is initially enabled

JMenuItemSpec

public JMenuItemSpec(JMenuItem mItem,
                     String cmd,
                     int acc,
                     int accMod)
Creates a JMenuItemSpec where the initial enabled status is determined by the default setting and the mnemonic is auto-assigned.

Parameters:
mItem - a JMenuItem object to which the remaining parameters apply
cmd - an action command for the menu item, used as an ID of the item
acc - a keyboard accelerator (key which selects item without an open menu)
accMod - a modifier key for the accelerator (CTRL, ALT, SHIFT, or none)

JMenuItemSpec

public JMenuItemSpec(JMenuItem mItem,
                     String cmd,
                     int acc)
Creates a JMenuItemSpec where the initial enabled status and the accelerator modifier are determined by the default setting, and the mnemonic is auto-assigned.

Parameters:
mItem - a JMenuItem object to which the remaining parameters apply
cmd - an action command for the menu item, used as an ID of the item
acc - a keyboard accelerator (key which selects item without an open menu)

JMenuItemSpec

public JMenuItemSpec(JMenuItem mItem,
                     String cmd)
Creates a JMenuItemSpec without an accelerator key, where the initial enabled status is determined by the default setting, and the mnemonic is auto-assigned.

Parameters:
mItem - a JMenuItem object to which the remaining parameters apply
cmd - an action command for the menu item, used as an ID of the item

JMenuItemSpec

public JMenuItemSpec()
Creates a JMenuItemSpec which specifies a menu separator.

Method Detail

setDefaultAccModifier

public void setDefaultAccModifier(int newDefaultAccModifier)
Changes the default accelerator modifier used by the constructors which omit one. Possible values are: ActionEvent.ALT_MASK, ActionEvent.CTRL_MASK, ActionEvent.SHIFT_MASK, or ActionEvent.META_MASK Each of these is a bit flag; they may be combined by logical OR operations (for example, to use SHIFT and ALT together). Alternately, the absence of any bits (a zero value) indicates to use no modifier key.

Parameters:
newDefaultAccModifier - a modifier mask for the accelerator key

setDefaultEnable

public void setDefaultEnable(boolean enable)
Changes the default enabled status used by the constructors which omit one.

Parameters:
enable - an initial enabled status for menu items


CleanCode Java Libraries Copyright © 2001-2012 Michael Sorens - Revised 2012.12.10 Get CleanCode at SourceForge.net. Fast, secure and Free Open Source software downloads