public class MenuUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
MENU_SEPARATOR
Separator flag
|
| Constructor and Description |
|---|
MenuUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.reflect.Method |
findMethod(java.lang.Class c,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Find all methods with the given name.
|
static javax.swing.JCheckBoxMenuItem |
makeCheckboxMenuItem(java.lang.String label,
java.lang.Object object,
java.lang.String property,
boolean value,
java.lang.Object arg)
Make a checkbox menu item.
|
static javax.swing.JCheckBoxMenuItem |
makeCheckboxMenuItem(java.lang.String label,
java.lang.Object object,
java.lang.String property,
java.lang.Object arg)
Make a checkbox menu item.
|
static javax.swing.JMenu |
makeMenu(javax.swing.JMenu menu,
java.util.List menuItems)
Create a JMenu and add the menus contained with the menus list
If no menus then return null.
|
static javax.swing.JMenu |
makeMenu(java.lang.String name,
java.util.List menuItems)
Create a JMenu and add the menus contained with the menus list
If no menus then return null.
|
static javax.swing.JMenuItem |
makeMenuItem(java.lang.String label,
java.lang.Object object,
java.lang.String methodName)
Make a jmenuItem.
|
static javax.swing.JMenuItem |
makeMenuItem(java.lang.String label,
java.lang.Object object,
java.lang.String methodName,
java.lang.Object arg)
Make a jmenuItem.
|
static javax.swing.JMenuItem |
makeMenuItem(java.lang.String label,
java.lang.Object object,
java.lang.String methodName,
java.lang.Object arg,
boolean inThread)
Make a jmenuItem.
|
static java.util.List |
makeMenuItems(java.lang.Object object,
java.lang.Object[][] items)
Utility to make a list of menu items.
|
static javax.swing.JPopupMenu |
makePopupMenu(javax.swing.JPopupMenu menu,
java.util.List menuItems)
Create a JPopupMenu and add the menus contained with the menus list
If no menus then return null.
|
static javax.swing.JPopupMenu |
makePopupMenu(java.util.List menuItems)
Create a JPopupMenu and add the menus contained with the menus list
If no menus then return null.
|
static void |
showPopupMenu(java.util.List menuItems,
java.awt.Component comp)
Create a popup menu and show it near the given component
|
static boolean |
typesMatch(java.lang.Class[] formals,
java.lang.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.
|
public static final java.lang.String MENU_SEPARATOR
public static boolean typesMatch(java.lang.Class[] formals,
java.lang.Class[] actuals)
formals - formal classes (types)actuals - actual classespublic static java.lang.reflect.Method findMethod(java.lang.Class c,
java.lang.String methodName,
java.lang.Class[] paramTypes)
c - class to checkmethodName - name of methodparamTypes - parameter typesnull if one doesn't existpublic static javax.swing.JMenuItem makeMenuItem(java.lang.String label,
java.lang.Object object,
java.lang.String methodName,
java.lang.Object arg)
label - Labelobject - Object to callmethodName - Method name to callarg - Pass this to method name if non-null.public static javax.swing.JMenuItem makeMenuItem(java.lang.String label,
java.lang.Object object,
java.lang.String methodName)
label - Labelobject - Object to callmethodName - Method name to callpublic static javax.swing.JMenuItem makeMenuItem(java.lang.String label,
java.lang.Object object,
java.lang.String methodName,
java.lang.Object arg,
boolean inThread)
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 threadpublic static javax.swing.JCheckBoxMenuItem makeCheckboxMenuItem(java.lang.String label,
java.lang.Object object,
java.lang.String property,
java.lang.Object arg)
label - Labelobject - Object to callproperty - Name of property to get/set valuearg - Optional arg to pass to methodpublic static javax.swing.JCheckBoxMenuItem makeCheckboxMenuItem(java.lang.String label,
java.lang.Object object,
java.lang.String property,
boolean value,
java.lang.Object arg)
label - Labelobject - Object to callproperty - Name of property to get/set valuevalue - The valuearg - Optional arg to pass to methodpublic static javax.swing.JMenu makeMenu(java.lang.String name,
java.util.List menuItems)
name - The menu namemenuItems - List of either, JMenu, JMenuItem or MENU_SEPARATORpublic static javax.swing.JMenu makeMenu(javax.swing.JMenu menu,
java.util.List menuItems)
menu - The menu to add tomenuItems - List of either, JMenu, JMenuItem or MENU_SEPARATORpublic static java.util.List makeMenuItems(java.lang.Object object,
java.lang.Object[][] items)
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.public static void showPopupMenu(java.util.List menuItems,
java.awt.Component comp)
menuItems - List of menu itemscomp - Component to show the menu atpublic static javax.swing.JPopupMenu makePopupMenu(javax.swing.JPopupMenu menu,
java.util.List menuItems)
menu - The menumenuItems - List of either, JMenu, JMenuItem or MENU_SEPARATORpublic static javax.swing.JPopupMenu makePopupMenu(java.util.List menuItems)
menuItems - List of either, JMenu, JMenuItem or MENU_SEPARATOR