Package ucar.unidata.util
Class MenuUtil
java.lang.Object
ucar.unidata.util.MenuUtil
- Direct Known Subclasses:
LayoutUtil
This is a vast catchall class to old various
utilities for doing GUI things.
- Author:
- IDV development team
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Method
findMethod
(Class c, String methodName, Class[] paramTypes) Find all methods with the given name.static JCheckBoxMenuItem
makeCheckboxMenuItem
(String label, Object object, String property, boolean value, Object arg) Make a checkbox menu item.static JCheckBoxMenuItem
makeCheckboxMenuItem
(String label, Object object, String property, Object arg) Make a checkbox menu item.static JMenu
Create a JMenu and add the menus contained with the menus list If no menus then return null.static JMenu
Create a JMenu and add the menus contained with the menus list If no menus then return null.static JMenuItem
makeMenuItem
(String label, Object object, String methodName) Make a jmenuItem.static JMenuItem
makeMenuItem
(String label, Object object, String methodName, Object arg) Make a jmenuItem.static JMenuItem
makeMenuItem
(String label, Object object, String methodName, Object arg, boolean inThread) Make a jmenuItem.static List
makeMenuItems
(Object object, Object[][] items) Utility to make a list of menu items.static JPopupMenu
makePopupMenu
(List menuItems) Create a JPopupMenu and add the menus contained with the menus list If no menus then return null.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.static void
showPopupMenu
(List menuItems, Component comp) Create a popup menu and show it near the given componentstatic 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.
-
Field Details
-
MENU_SEPARATOR
Separator flag- See Also:
-
-
Constructor Details
-
MenuUtil
public MenuUtil()
-
-
Method Details
-
typesMatch
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
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 checkmethodName
- name of methodparamTypes
- parameter types- Returns:
- class method or
null
if one doesn't exist
-
makeMenuItem
Make a jmenuItem. Call methodName on object when menuItem pressed. Pass in given arg if non-null.- Parameters:
label
- Labelobject
- Object to callmethodName
- Method name to callarg
- Pass this to method name if non-null.- Returns:
- The menuItem
-
makeMenuItem
Make a jmenuItem. Call methodName on object when menuItem pressed.- Parameters:
label
- Labelobject
- Object to callmethodName
- 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
- Labelobject
- Object to callmethodName
- Method name to callarg
- 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
- Labelobject
- Object to callproperty
- Name of property to get/set valuearg
- 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
- Labelobject
- Object to callproperty
- Name of property to get/set valuevalue
- The valuearg
- Optional arg to pass to method- Returns:
- The checkbox
-
makeMenu
Create a JMenu and add the menus contained with the menus list If no menus then return null.- Parameters:
name
- The menu namemenuItems
- List of either, JMenu, JMenuItem or MENU_SEPARATOR- Returns:
- The new menu
-
makeMenu
Create a JMenu and add the menus contained with the menus list If no menus then return null.- Parameters:
menu
- The menu to add tomenuItems
- List of either, JMenu, JMenuItem or MENU_SEPARATOR- Returns:
- The given menu
-
makeMenuItems
Utility to make a list of menu items.- Parameters:
object
- The object to call the method onitems
- 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
Create a popup menu and show it near the given component- Parameters:
menuItems
- List of menu itemscomp
- Component to show the menu at
-
makePopupMenu
Create a JPopupMenu and add the menus contained with the menus list If no menus then return null.- Parameters:
menu
- The menumenuItems
- List of either, JMenu, JMenuItem or MENU_SEPARATOR- Returns:
- The given menu
-
makePopupMenu
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
-