Class MenuUtil

java.lang.Object
ucar.unidata.util.MenuUtil
Direct Known Subclasses:
LayoutUtil

public class MenuUtil extends Object
This is a vast catchall class to old various utilities for doing GUI things.
Author:
IDV development team
  • Field Details

  • Constructor Details

    • MenuUtil

      public MenuUtil()
  • Method Details

    • typesMatch

      public static boolean typesMatch(Class[] formals, Class[] actuals)
      Returns true if the Classes defined in the actual parameter are equal or a sub-class of the corresponding classes defined in the formal argument.
      Parameters:
      formals - formal classes (types)
      actuals - actual classes
      Returns:
      true if they match
    • findMethod

      public static Method findMethod(Class c, String methodName, Class[] paramTypes)
      Find all methods with the given name. Of these methods find one whose parameter types are assignable from the given parameter types.
      Parameters:
      c - class to check
      methodName - name of method
      paramTypes - parameter types
      Returns:
      class method or null if one doesn't exist
    • makeMenuItem

      public static JMenuItem makeMenuItem(String label, Object object, String methodName, Object arg)
      Make a jmenuItem. Call methodName on object when menuItem pressed. Pass in given arg if non-null.
      Parameters:
      label - Label
      object - Object to call
      methodName - Method name to call
      arg - Pass this to method name if non-null.
      Returns:
      The menuItem
    • makeMenuItem

      public static JMenuItem makeMenuItem(String label, Object object, String methodName)
      Make a jmenuItem. Call methodName on object when menuItem pressed.
      Parameters:
      label - Label
      object - Object to call
      methodName - Method name to call
      Returns:
      The menuItem
    • makeMenuItem

      public static JMenuItem makeMenuItem(String label, Object object, String methodName, Object arg, boolean inThread)
      Make a jmenuItem. Call methodName on object when menuItem pressed. Pass in given arg if non-null.
      Parameters:
      label - Label
      object - Object to call
      methodName - Method name to call
      arg - Pass this to method name if non-null.
      inThread - If true then call the method in a thread
      Returns:
      The menuItem
    • makeCheckboxMenuItem

      public static JCheckBoxMenuItem makeCheckboxMenuItem(String label, Object object, String property, Object arg)
      Make a checkbox menu item. Automatically call the set'property' method on the object
      Parameters:
      label - Label
      object - Object to call
      property - Name of property to get/set value
      arg - Optional arg to pass to method
      Returns:
      The checkbox
    • makeCheckboxMenuItem

      public static JCheckBoxMenuItem makeCheckboxMenuItem(String label, Object object, String property, boolean value, Object arg)
      Make a checkbox menu item. Automatically call the set'property' method on the object
      Parameters:
      label - Label
      object - Object to call
      property - Name of property to get/set value
      value - The value
      arg - Optional arg to pass to method
      Returns:
      The checkbox
    • makeMenu

      public static JMenu makeMenu(String name, List menuItems)
      Create a JMenu and add the menus contained with the menus list If no menus then return null.
      Parameters:
      name - The menu name
      menuItems - List of either, JMenu, JMenuItem or MENU_SEPARATOR
      Returns:
      The new menu
    • makeMenu

      public static JMenu makeMenu(JMenu menu, List menuItems)
      Create a JMenu and add the menus contained with the menus list If no menus then return null.
      Parameters:
      menu - The menu to add to
      menuItems - List of either, JMenu, JMenuItem or MENU_SEPARATOR
      Returns:
      The given menu
    • makeMenuItems

      public static List makeMenuItems(Object object, Object[][] items)
      Utility to make a list of menu items.
      Parameters:
      object - The object to call the method on
      items - An array. Each sub array has at least two elements:
       {Menu name, method name}
       
      If it has 3 elements then the 3rd element is an argument that is also passed to the method. If it has 4 elements then the 4th element is a tooltip. If there are 4 elements and the 3rd element is null then we don't try to find a method that tags an extra argument.
      Returns:
      List of menu items
    • showPopupMenu

      public static void showPopupMenu(List menuItems, Component comp)
      Create a popup menu and show it near the given component
      Parameters:
      menuItems - List of menu items
      comp - Component to show the menu at
    • makePopupMenu

      public static JPopupMenu makePopupMenu(JPopupMenu menu, List menuItems)
      Create a JPopupMenu and add the menus contained with the menus list If no menus then return null.
      Parameters:
      menu - The menu
      menuItems - List of either, JMenu, JMenuItem or MENU_SEPARATOR
      Returns:
      The given menu
    • makePopupMenu

      public static JPopupMenu makePopupMenu(List menuItems)
      Create a JPopupMenu and add the menus contained with the menus list If no menus then return null.
      Parameters:
      menuItems - List of either, JMenu, JMenuItem or MENU_SEPARATOR
      Returns:
      The new popup menu