Java JPopupMenu addOption(JPopupMenu popupMenu, String text, String key, ActionListener actionListener)

Here you can find the source of addOption(JPopupMenu popupMenu, String text, String key, ActionListener actionListener)

Description

add Option

License

Apache License

Declaration

public static KeyStroke addOption(JPopupMenu popupMenu, String text, String key,
            ActionListener actionListener) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.swing.*;
import java.awt.event.ActionListener;

public class Main {
    public static KeyStroke addOption(JPopupMenu popupMenu, String text, String key,
            ActionListener actionListener) {
        JMenuItem option = new JMenuItem(text);
        KeyStroke keyStroke = KeyStroke.getKeyStroke(key);
        option.setAccelerator(keyStroke);
        option.addActionListener(actionListener);
        popupMenu.add(option);//w  ww. j a  va2s .  c  om

        return keyStroke;
    }
}

Related

  1. addMenuItem(JPopupMenu menu, Action action)
  2. addMenuItems(JPopupMenu menu, JComponent... items)
  3. addPopup(Component component, final JPopupMenu popup)
  4. addPopup(Component component, final JPopupMenu popup)
  5. addPopup(final Component c, final JPopupMenu m)
  6. addSeparatorIfNecessary(JPopupMenu popup)