Java Swing Menu Item createMenuItem(ActionListener listener, String cmd, String toolTip)

Here you can find the source of createMenuItem(ActionListener listener, String cmd, String toolTip)

Description

create Menu Item

License

BSD License

Declaration

public static JMenuItem createMenuItem(ActionListener listener, String cmd, String toolTip) 

Method Source Code

//package com.java2s;
/**//from  w w  w. j  a v  a  2s  .c  om
 * Copyright (c) 2014, by the Authors: John E Lloyd (UBC)
 *
 * This software is freely available under a 2-clause BSD license. Please see
 * the LICENSE file in the ArtiSynth distribution directory for details.
 */

import java.awt.event.ActionListener;

import javax.swing.JMenuItem;

public class Main {
    public static JMenuItem createMenuItem(ActionListener listener, String cmd, String toolTip) {
        JMenuItem item = new JMenuItem(cmd);
        item.setActionCommand(cmd);
        item.addActionListener(listener);
        item.setToolTipText(toolTip);
        return item;
    }
}

Related

  1. addMenuItem(final Action action, final C topLevelMenu, final String... path)
  2. appendMenuItem(Component menuItem, StringBuilder builder, String indent)
  3. createMenu(String menu, String[] menuItemNames)
  4. createMenuItem(Action a)
  5. createMenuItem(Action action, Icon icon)
  6. createMenuItem(final String label, final String accessibleDescription, final ActionListener actionListener)
  7. createMenuItem(final String text, final ActionListener al, final int mnemonic)
  8. createMenuItem(final String text, final Icon icon)
  9. createMenuItem(String caption, Action action)