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

_more_

License

Open Source License

Parameter

Parameter Description
icon a parameter
rollover a parameter
menu_cmd a parameter
is_toggle a parameter
mnemonic a parameter
accel a parameter

Return

_more_

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;
/*//w ww.j a  v a 2s. c  o  m
 * $Id: BAMutil.java,v 1.16 2007/07/06 20:45:29 jeffmc Exp $
 *
 * Copyright  1997-2015 Unidata Program Center/University Corporation for
 * Atmospheric Research, P.O. Box 3000, Boulder, CO 80307,
 * support@unidata.ucar.edu.
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
 * General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

import javax.swing.*;

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

    /**
     * _more_
     *
     * @param icon
     * @param rollover
     * @param menu_cmd
     * @param is_toggle
     * @param mnemonic
     * @param accel
     * @return _more_
     */
    private static JMenuItem makeMenuItem(Icon icon, Icon rollover,
            String menu_cmd, boolean is_toggle, int mnemonic, int accel) {
        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) {
            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. getTopicsMenuItem(ActionListener l)
  2. isSynthUI(final MenuItemUI ui)
  3. loadMenuItem(String action)
  4. makeCheckboxMenuItem(String label, final Object object, final String property, final Object arg)
  5. makeMenu(String name, List menuItems)
  6. makeMenuItem(Icon icon, Icon rollover, String menu_cmd, boolean is_toggle, int mnemonic, int accel)
  7. makeMenuItem(String label, final Object object, final String methodName)
  8. makeMenuItem(String s, ActionListener listener)
  9. makeMenuItem(URL iconURL, String text, ActionListener listener)