Java Swing Menu Item createMenuItem(final String text, final Icon icon)

Here you can find the source of createMenuItem(final String text, final Icon icon)

Description

create Menu Item

License

Open Source License

Declaration

public static JMenuItem createMenuItem(final String text, final Icon icon) 

Method Source Code


//package com.java2s;
/* This file is part of the project "Hilbert II" - http://www.qedeq.org
 *
 * Copyright 2000-2013,  Michael Meyling <mime@qedeq.org>.
 *
 * "Hilbert II" is free software; you can redistribute
 * it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 */// w w  w .  j  a  v a  2  s.com

import javax.swing.Icon;

import javax.swing.JMenuItem;

import javax.swing.KeyStroke;

public class Main {
    public static JMenuItem createMenuItem(final String text) {
        return new JMenuItem(text);
    }

    public static JMenuItem createMenuItem(final String text, final char mnemonic) {
        return new JMenuItem(text, mnemonic);
    }

    public static JMenuItem createMenuItem(final String text, final char mnemonic, final KeyStroke key) {
        JMenuItem menuItem = new JMenuItem(text, mnemonic);
        menuItem.setAccelerator(key);
        return menuItem;
    }

    public static JMenuItem createMenuItem(final String text, final Icon icon) {
        return new JMenuItem(text, icon);
    }

    public static JMenuItem createMenuItem(final String text, final Icon icon, final char mnemonic) {
        final JMenuItem menuItem = new JMenuItem(text, icon);
        menuItem.setMnemonic(mnemonic);
        return menuItem;
    }

    public static JMenuItem createMenuItem(final String text, final Icon icon, final char mnemonic,
            final KeyStroke key) {
        final JMenuItem menuItem = createMenuItem(text, icon, mnemonic);
        menuItem.setAccelerator(key);
        return menuItem;
    }
}

Related

  1. createMenuItem(Action a)
  2. createMenuItem(Action action, Icon icon)
  3. createMenuItem(ActionListener listener, String cmd, String toolTip)
  4. createMenuItem(final String label, final String accessibleDescription, final ActionListener actionListener)
  5. createMenuItem(final String text, final ActionListener al, final int mnemonic)
  6. createMenuItem(String caption, Action action)
  7. createMenuItem(String menuItemName, ActionListener actionListener)
  8. createMenuItem(String menuText, ActionListener listener)
  9. createMenuitem(String name, ActionListener listener)