Module ij
Package ij

# Class Menus

java.lang.Object
ij.Menus

public class Menus extends Object
This class installs and updates ImageJ's menus. Note that menu labels, even in submenus, must be unique. This is because ImageJ uses a single hash table for all menu labels. If you look closely, you will see that File->Import->Text Image... and File->Save As->Text Image... do not use the same label. One of the labels has an extra space.

See Also:
  - `ImageJ`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final char`
`ABOUT_MENU`
`static final int`
`COMMAND_IN_USE`
`static final int`
`COMMAND_NOT_FOUND`
`static final char`
`FILTERS_MENU`
`static final char`
`IMPORT_MENU`
`static final int`
`INVALID_SHORTCUT`
`static final int`
`MAX_OPEN_RECENT_ITEMS`
`static final int`
`NORMAL_RETURN`
`static final int`
`NOT_INSTALLED`
`static final char`
`PLUGINS_MENU`
`static final char`
`SAVE_AS_MENU`
`static int`
`setMenuBarCount`
`static final int`
`SHORTCUT_IN_USE`
`static final char`
`SHORTCUTS_MENU`
`static final char`
`TOOLS_MENU`
`static final char`
`UTILITIES_MENU`
`static final int`
`WINDOW_MENU_ITEMS`

## Method Summary

Modifier and Type
Method
Description
`static void`
`add(String menuPath, String plugin)`
Adds a command to the ImageJ menu bar.
`static void`
`addOpenRecentItem(String path)`
Adds a file path to the beginning of the File/Open Recent submenu.
`static boolean`
`commandInUse(String command)`
`static int`
`convertShortcutToCode(String shortcut)`
`static Font`
`getCachedFont()`
`static Hashtable`
`getCommands()`
Returns the hashtable that associates commands with plugins.
`static Menu`
`getExamplesMenu(ActionListener listener)`
`static Font`
`getFont()`
`static Font`
`getFont(boolean checkSize)`
`static int`
`getFontSize()`
Returns the size (in points) used for the fonts in ImageJ menus.
`static Menu`
`getImageJMenu(String menuPath)`
Returns the specified ImageJ menu (e.g., "File>New") or null if it is not found.
`static String`
`getJarFileForMenuEntry(String menuEntry)`
`int`
`getMacroCount()`
`static Hashtable`
`getMacroShortcuts()`
Returns the hashtable that associates keyboard shortcuts with macros.
`static Menu`
`getMacrosMenu()`
`static String`
`getMacrosPath()`
Returns the path to the macros directory or null if the macros directory was not found.
`static MenuBar`
`getMenuBar()`
`static Menu`
`getOpenRecentMenu()`
`int`
`getPluginCount()`
`static String[]`
`getPlugins()`
Returns a list of the plugins in the plugins menu.
`static String`
`getPlugInsPath()`
Returns the path to the user plugins directory or null if the plugins directory was not found.
`static PopupMenu`
`getPopupMenu()`
`static Menu`
`getSaveAsMenu()`
`static Hashtable`
`getShortcuts()`
Returns the hashtable that associates shortcuts with commands.
`static int`
`installPlugin(String plugin, char menuCode, String command, String shortcut, ImageJ ij)`
Adds a plugin based command to the end of a specified menu.
`void`
`installUserPlugin(String className, boolean force)`
`static void`
`savePreferences(Properties prefs)`
Called once when ImageJ quits.
`static void`
`setFontSize(int size)`
Set the size (in points) used for the fonts in ImageJ menus.
`static boolean`
`shortcutInUse(String shortcut)`
Returns 'true' if this keyboard shortcut is in use.
`static int`
`uninstallPlugin(String command)`
Deletes a command installed by Plugins/Shortcuts/Add Shortcut.
`static void`
`updateFont()`
`static void`
`updateImageJMenus()`
`static void`
`updateMenus()`
Updates the Image/Type and Window menus.
`static void`
`updateWindowMenuItem(ImagePlus imp, String oldLabel, String newLabel)`
Changes the name of an item in the Window menu.
`static void`
`updateWindowMenuItem(String oldLabel, String newLabel)`
Changes the name of an item in the Window menu.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### PLUGINS_MENU

public static final char PLUGINS_MENU

See Also:
  - Constant Field Values

### IMPORT_MENU

public static final char IMPORT_MENU

See Also:
  - Constant Field Values

### SAVE_AS_MENU

public static final char SAVE_AS_MENU

See Also:
  - Constant Field Values

### SHORTCUTS_MENU

public static final char SHORTCUTS_MENU

See Also:
  - Constant Field Values

### ABOUT_MENU

public static final char ABOUT_MENU

See Also:
  - Constant Field Values

### FILTERS_MENU

public static final char FILTERS_MENU

See Also:
  - Constant Field Values

### TOOLS_MENU

public static final char TOOLS_MENU

See Also:
  - Constant Field Values

### UTILITIES_MENU

public static final char UTILITIES_MENU

See Also:
  - Constant Field Values

### WINDOW_MENU_ITEMS

public static final int WINDOW_MENU_ITEMS

See Also:
  - Constant Field Values

### NORMAL_RETURN

public static final int NORMAL_RETURN

See Also:
  - Constant Field Values

### COMMAND_IN_USE

public static final int COMMAND_IN_USE

See Also:
  - Constant Field Values

### INVALID_SHORTCUT

public static final int INVALID_SHORTCUT

See Also:
  - Constant Field Values

### SHORTCUT_IN_USE

public static final int SHORTCUT_IN_USE

See Also:
  - Constant Field Values

### NOT_INSTALLED

public static final int NOT_INSTALLED

See Also:
  - Constant Field Values

### COMMAND_NOT_FOUND

public static final int COMMAND_NOT_FOUND

See Also:
  - Constant Field Values

### MAX_OPEN_RECENT_ITEMS

public static final int MAX_OPEN_RECENT_ITEMS

See Also:
  - Constant Field Values

### setMenuBarCount

public static int setMenuBarCount

## Method Details

### getExamplesMenu

public static Menu getExamplesMenu(ActionListener listener)

### getJarFileForMenuEntry

public static String getJarFileForMenuEntry(String menuEntry)

### getImageJMenu

public static Menu getImageJMenu(String menuPath)
Returns the specified ImageJ menu (e.g., "File>New") or null if it is not found.

### getPlugins

public static String[] getPlugins()
Returns a list of the plugins in the plugins menu.

### installUserPlugin

public void installUserPlugin(String className, boolean force)

### getMenuBar

public static MenuBar getMenuBar()

### getMacrosMenu

public static Menu getMacrosMenu()

### getOpenRecentMenu

public static Menu getOpenRecentMenu()

### getMacroCount

public int getMacroCount()

### getPluginCount

public int getPluginCount()

### updateMenus

public static void updateMenus()
Updates the Image/Type and Window menus.

### getPlugInsPath

public static String getPlugInsPath()
Returns the path to the user plugins directory or null if the plugins directory was not found.

### getMacrosPath

public static String getMacrosPath()
Returns the path to the macros directory or null if the macros directory was not found.

### getCommands

public static Hashtable getCommands()
Returns the hashtable that associates commands with plugins.

### getShortcuts

public static Hashtable getShortcuts()
Returns the hashtable that associates shortcuts with commands. The keys in the hashtable are Integer keycodes, or keycode+200 for uppercase.

### getMacroShortcuts

public static Hashtable getMacroShortcuts()
Returns the hashtable that associates keyboard shortcuts with macros. The keys in the hashtable are Integer keycodes, or keycode+200 for uppercase.

### updateWindowMenuItem

public static void updateWindowMenuItem(String oldLabel, String newLabel)
Changes the name of an item in the Window menu.

### updateWindowMenuItem

public static void updateWindowMenuItem(ImagePlus imp, String oldLabel, String newLabel)
Changes the name of an item in the Window menu.

### addOpenRecentItem

public static void addOpenRecentItem(String path)
Adds a file path to the beginning of the File/Open Recent submenu.

### getPopupMenu

public static PopupMenu getPopupMenu()

### getSaveAsMenu

public static Menu getSaveAsMenu()

### installPlugin

public static int installPlugin(String plugin, char menuCode, String command, String shortcut, ImageJ ij)
Adds a plugin based command to the end of a specified menu.

Parameters:
  `plugin` - the plugin (e.g. "Inverter_", "Inverter_("arg")")
  `menuCode` - PLUGINS_MENU, IMPORT_MENU, SAVE_AS_MENU or HOT_KEYS
  `command` - the menu item label (set to "" to uninstall)
  `shortcut` - the keyboard shortcut (e.g. "y", "Y", "F1")
  `ij` - ImageJ (the action listener)
Returns:
  returns an error code(NORMAL_RETURN,COMMAND_IN_USE_ERROR, etc.)

### uninstallPlugin

public static int uninstallPlugin(String command)
Deletes a command installed by Plugins/Shortcuts/Add Shortcut.

### commandInUse

public static boolean commandInUse(String command)

### convertShortcutToCode

public static int convertShortcutToCode(String shortcut)

### shortcutInUse

public static boolean shortcutInUse(String shortcut)
Returns 'true' if this keyboard shortcut is in use.

### setFontSize

public static void setFontSize(int size)
Set the size (in points) used for the fonts in ImageJ menus. Set the size to 0 to use the Java default size.

### getFontSize

public static int getFontSize()
Returns the size (in points) used for the fonts in ImageJ menus. Returns 0 if the default font size is being used or if this is a Macintosh.

### getFont

public static Font getFont()

### getFont

public static Font getFont(boolean checkSize)

### getCachedFont

public static Font getCachedFont()

### savePreferences

public static void savePreferences(Properties prefs)
Called once when ImageJ quits.

### updateImageJMenus

public static void updateImageJMenus()

### updateFont

public static void updateFont()

### add

public static void add(String menuPath, String plugin)
Adds a command to the ImageJ menu bar.