Java Swing Menu Item createMenuitem(String name, ActionListener listener)

Here you can find the source of createMenuitem(String name, ActionListener listener)

Description

create Menuitem

License

Open Source License

Declaration

public static JMenuItem createMenuitem(String name, ActionListener listener) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.event.ActionListener;

import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

public class Main {
    public static JMenuItem createMenuitem(String name, ActionListener listener) {
        final JMenuItem button = new JMenuItem(name);
        button.addActionListener(listener);
        return button;
    }//from  w  w w.j  a  v  a  2  s.  c o m

    public static JMenuItem createMenuitem(String name, ActionListener listener, String keyBind) {
        final JMenuItem button = new JMenuItem(name);
        button.addActionListener(listener);
        button.setAccelerator(KeyStroke.getKeyStroke(keyBind));
        return button;
    }
}

Related

  1. createMenuItem(final String text, final ActionListener al, final int mnemonic)
  2. createMenuItem(final String text, final Icon icon)
  3. createMenuItem(String caption, Action action)
  4. createMenuItem(String menuItemName, ActionListener actionListener)
  5. createMenuItem(String menuText, ActionListener listener)
  6. createMenuItem(String name, String description, int mnemonic, int accelerator, ActionListener listener)
  7. createMenuItem(String strTitle, String strActionCommand, ActionListener alListener)
  8. createMenuItem(String text, boolean visible)
  9. createMenuItem(String text, Icon icon, String toolTip, ActionListener... listeners)