Java Swing Menu Item makeMenuItem(Icon icon, Icon rollover, String menu_cmd, boolean is_toggle, int mnemonic, int accel)

Here you can find the source of makeMenuItem(Icon icon, Icon rollover, String menu_cmd, boolean is_toggle, int mnemonic, int accel)

Description

make Menu Item

License

Open Source License

Declaration

private static JMenuItem makeMenuItem(Icon icon, Icon rollover,
            String menu_cmd, boolean is_toggle, int mnemonic, int accel) 

Method Source Code

//package com.java2s;

import javax.swing.*;

public class Main {
    static final private int META_KEY = java.awt.Event.CTRL_MASK;

    private static JMenuItem makeMenuItem(Icon icon, Icon rollover,
            String menu_cmd, boolean is_toggle, int mnemonic, int accel) {
        JMenuItem mi;/*from   w ww .j  a  v a2  s. c o m*/
        if (is_toggle)
            mi = new JCheckBoxMenuItem(menu_cmd);
        else
            mi = new JMenuItem(menu_cmd);

        if (icon != null)
            mi.setIcon(icon);
        if (rollover != null) {
            mi.setRolloverIcon(rollover);
            mi.setRolloverSelectedIcon(rollover);
            mi.setPressedIcon(rollover);
            mi.setRolloverEnabled(true);
        }

        mi.setHorizontalTextPosition(SwingConstants.LEFT);
        if (mnemonic != 0)
            mi.setMnemonic(mnemonic);
        if (accel != 0)
            mi.setAccelerator(KeyStroke.getKeyStroke(accel, META_KEY));

        return mi;
    }
}

Related

  1. isSynthUI(final MenuItemUI ui)
  2. loadMenuItem(String action)
  3. makeCheckboxMenuItem(String label, final Object object, final String property, final Object arg)
  4. makeMenu(String name, List menuItems)
  5. makeMenuItem(Icon icon, Icon rollover, String menu_cmd, boolean is_toggle, int mnemonic, int accel)
  6. makeMenuItem(String label, final Object object, final String methodName)
  7. makeMenuItem(String s, ActionListener listener)
  8. makeMenuItem(URL iconURL, String text, ActionListener listener)
  9. newMenuItem(String name, KeyStroke keyStroke, final Runnable runnable)