Java JMenuItem createJMenuItem(Action action)

Here you can find the source of createJMenuItem(Action action)

Description

Creates a menu item from specified action.

License

Open Source License

Declaration

public static JMenuItem createJMenuItem(Action action) 

Method Source Code


//package com.java2s;
import java.awt.event.ActionListener;
import javax.swing.Action;

import javax.swing.JMenuItem;

public class Main {
    /**/*from   w w  w .  j av a  2 s  .  c o  m*/
     * Creates a menu item from specified action.
     */
    public static JMenuItem createJMenuItem(Action action) {
        JMenuItem item = new JMenuItem(action);
        item.setActionCommand((String) action.getValue(Action.ACTION_COMMAND_KEY));
        return item;
    }

    /**
     * Creates a menu item with specified name and acton command.
     */
    public static JMenuItem createJMenuItem(String name, String command, ActionListener listener) {
        JMenuItem item = new JMenuItem(name);
        item.setActionCommand(command);
        item.addActionListener(listener);
        return item;
    }
}

Related

  1. aplicarMenu(JMenuItem loMenuO, JMenuItem loMenuD)
  2. applyDefaultProperties(final JMenuItem comp)
  3. attachAcceleratorKeyNoCtrl(JMenuItem item, int keyEvent)
  4. cloneMenuItem(final JMenuItem item)
  5. configureMenuItem(JMenuItem item, Action action)
  6. createJMenuItem(JMenu menu, String text, int mnemonic, int acceleratorKey, String toolTip, ActionListener actionListener)
  7. createMenu(JMenuItem[] items, String name, String description, int mnemonic)
  8. exit(JMenuItem anItem)
  9. getForeground(final BasicMenuItemUI ui, final JMenuItem menuItem)