Class IMenuItem

All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, MenuElement, SwingConstants

public class IMenuItem extends JMenuItem
Menu with internationalization support. The constructors take the name of a resource bundle and keys used to look up menu names and icons from the bundle. Changing the locale then automatically changes the icon and/or menu name.
See Also:
  • Constructor Details

    • IMenuItem

      public IMenuItem()
      Constructor.
    • IMenuItem

      public IMenuItem(Action a)
      Constructor given an Action.
      Parameters:
      a - the action that determine this menu item's appearance and behavior
    • IMenuItem

      public IMenuItem(Icon icon)
      Constructor given an Icon
      Parameters:
      icon - the icon that represents this menu item.
    • IMenuItem

      public IMenuItem(String text)
      Constructor given specified text.
      Parameters:
      text - the text that labels this menu item
    • IMenuItem

      public IMenuItem(String bundleName, String key) throws IllegalArgumentException
      Constructor given a bundle pathname and a key for text.
      Parameters:
      bundleName - the pathname of a resource bundle
      key - the resource bundle's key for the text labeling this menu item
      Throws:
      IllegalArgumentException - the path name for a resource bundle pointed to a resource that does not exist
    • IMenuItem

      public IMenuItem(Locale locale, String bundleName, String key) throws IllegalArgumentException
      Constructor given a locale, a bundle pathname and a key for text.
      Parameters:
      locale - a locale
      bundleName - the pathname of a resource bundle
      key - the resource bundle's key for the text labeling this menu item
      Throws:
      IllegalArgumentException - the path name for a resource bundle pointed to a resource that does not exist
    • IMenuItem

      public IMenuItem(String bundleName, String key1, String key2) throws IllegalArgumentException
      Constructor given a bundle pathname, a key for text, and a key for either an icon or a mnemonic.
      Parameters:
      bundleName - the pathname of a resource bundle
      key1 - the resource bundle's key for the text labeling this menu item
      key2 - the resource bundle's key for either an icon or for a mnemonic
      Throws:
      IllegalArgumentException - the path name for a resource bundle pointed to a resource that does not exist
    • IMenuItem

      public IMenuItem(Locale locale, String bundleName, String key1, String key2) throws IllegalArgumentException
      Constructor given a locale, a bundle pathname, a key for text, and a key for either an icon or a mnemonic. The resource bundle is expected to provide an object that is an Icon when key2 refers to an icon or an Integer when key2 refers to a mnemonic.
      Parameters:
      locale - the locale
      bundleName - the pathname of a resource bundle
      key1 - the resource bundle's key for the text labeling this menu item
      key2 - the resource bundle's key for either an icon or for a mnemonic
      Throws:
      IllegalArgumentException - the path name for a resource bundle pointed to a resource that does not exist
  • Method Details

    • setLocale

      public void setLocale(Locale locale)
      Overrides:
      setLocale in class Component
    • setText

      public void setText(String text)
      Overrides:
      setText in class AbstractButton
    • setTextKey

      public void setTextKey(String key)
      Set a menu item's text by key instead of by value.
      Parameters:
      key - the key used by a resource bundle to find the text used to label this menu item
    • setIcon

      public void setIcon(Icon icon)
      Overrides:
      setIcon in class AbstractButton
    • setIconKey

      public void setIconKey(String key)
      Set a menu item's icon by key instead of by value.
      Parameters:
      key - the key used by a resource bundle to find the icon for this menu item
      See Also:
    • setSelectedIcon

      public void setSelectedIcon(Icon icon)
      Overrides:
      setSelectedIcon in class AbstractButton
    • setSelectedIconKey

      public void setSelectedIconKey(String key)
      Set a menu item's selected icon by key instead of by value.
      Parameters:
      key - the key used by a resource bundle to find the icon for this menu item
      See Also:
    • setDisabledIcon

      public void setDisabledIcon(Icon icon)
      Overrides:
      setDisabledIcon in class AbstractButton
    • setDisabledIconKey

      public void setDisabledIconKey(String key)
      Set a menu item's disabled icon by key instead of by value.
      Parameters:
      key - the key used by a resource bundle to find the icon for this menu item
      See Also:
    • setDisabledSelectedIcon

      public void setDisabledSelectedIcon(Icon icon)
      Overrides:
      setDisabledSelectedIcon in class AbstractButton
    • setDisabledSelectedIconKey

      public void setDisabledSelectedIconKey(String key)
      Set a menu item's disabled-selected icon by key instead of by value.
      Parameters:
      key - the key used by a resource bundle to find the icon for this menu item
      See Also:
    • setRolloverIcon

      public void setRolloverIcon(Icon icon)
      Overrides:
      setRolloverIcon in class AbstractButton
    • setRolloverIconKey

      public void setRolloverIconKey(String key)
      Set a menu item's rollover icon by key instead of by value.
      Parameters:
      key - the key used by a resource bundle to find the icon for this menu item
      See Also:
    • setRolloverSelectedIcon

      public void setRolloverSelectedIcon(Icon icon)
      Overrides:
      setRolloverSelectedIcon in class AbstractButton
    • setRolloverSelectedIconKey

      public void setRolloverSelectedIconKey(String key)
      Set a menu item's rollover-selected icon by key instead of by value.
      Parameters:
      key - the key used by a resource bundle to find the icon for this menu item
      See Also:
    • setPressedIcon

      public void setPressedIcon(Icon icon)
      Overrides:
      setPressedIcon in class AbstractButton
    • setPressedIconKey

      public void setPressedIconKey(String key)
      Set a menu item's pressed icon by key instead of by value.
      Parameters:
      key - the key used by a resource bundle to find the icon for this menu item
      See Also:
    • setMnemonic

      public void setMnemonic(int mnemonic)
      Overrides:
      setMnemonic in class AbstractButton
    • setMnemonicKey

      public void setMnemonicKey(String key)
      Set a menu item's mnemonic code by key instead of by value.
      Parameters:
      key - the key used by a resource bundle to find the mnemonic code for this menu item
      See Also: