Java Utililty Methods Swing Menu Item

List of utility methods to do Swing Menu Item

Description

The list of methods to do Swing Menu Item are organized into topic(s).

Method

intgetTextOffset(JComponent menuItem, Component menuItemParent)
Returns the text offset of the specified menu item.
if (!(menuItemParent instanceof JPopupMenu)) {
    return 0;
Object itemProp = menuItem.getClientProperty(GUTTER_X);
if (itemProp instanceof Integer) {
    return (Integer) itemProp;
JPopupMenu popupMenu = (JPopupMenu) menuItemParent;
...
JCheckBoxMenuItemgetTexturesMenuItem()
get Textures Menu Item
texturesMenuItem.setToolTipText("Turn textures on/off");
return texturesMenuItem;
JPanelgetTopicsMenuItem(ActionListener l)
get Topics Menu Item
JPanel panel = new JPanel();
lexpand = new JButton(maxicon);
lexpand.setActionCommand("left-expand");
lexpand.setToolTipText("Expand window");
lexpand.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lexpand.setPreferredSize(new Dimension(16, 16));
lexpand.addActionListener(l);
panel.add(lexpand);
...
booleanisSynthUI(final MenuItemUI ui)
is Synth UI
Class<?> aClass = ui.getClass();
while (aClass != null && aClass.getSimpleName().contains("Synth")) {
    final Class<?>[] interfaces = aClass.getInterfaces();
    for (int i = 0, length = interfaces.length; i < length; i++) {
        final Class<?> anInterface = interfaces[i];
        if (V6_SYNTH_UI_CLASS.equals(anInterface.getName())
                || V7_SYNTH_UI_CLASS.equals(anInterface.getName())) {
            return true;
...
JMenuItemloadMenuItem(String action)
This method creates a new JMenuItem.
return null;
JCheckBoxMenuItemmakeCheckboxMenuItem(String label, final Object object, final String property, final Object arg)
Make a checkbox menu item.
boolean value = true;
try {
    String methodName = "get" + property.substring(0, 1).toUpperCase() + property.substring(1);
    Method theMethod = findMethod(object.getClass(), methodName,
            ((arg == null) ? new Class[] {} : new Class[] { arg.getClass() }));
    if (theMethod != null) {
        Boolean v = (Boolean) theMethod.invoke(object,
                ((arg == null) ? new Object[] {} : new Object[] { arg }));
...
JMenumakeMenu(String name, List menuItems)
Create a JMenu and add the menus contained with the menus list If no menus then return null.
return makeMenu(new JMenu(name), menuItems);
JMenuItemmakeMenuItem(Icon icon, Icon rollover, String menu_cmd, boolean is_toggle, int mnemonic, int accel)
_more_
JMenuItem mi;
if (is_toggle) {
    mi = new JCheckBoxMenuItem(menu_cmd);
} else {
    mi = new JMenuItem(menu_cmd);
if (icon != null) {
    mi.setIcon(icon);
...
JMenuItemmakeMenuItem(Icon icon, Icon rollover, String menu_cmd, boolean is_toggle, int mnemonic, int accel)
make Menu Item
JMenuItem mi;
if (is_toggle)
    mi = new JCheckBoxMenuItem(menu_cmd);
else
    mi = new JMenuItem(menu_cmd);
if (icon != null)
    mi.setIcon(icon);
if (rollover != null) {
...
JMenuItemmakeMenuItem(String label, final Object object, final String methodName)
Make a jmenuItem.
return makeMenuItem(label, object, methodName, null, false);