Java JCheckBoxMenuItem createCheckBoxMenuItem(String label, int mnemonic, String description, ItemListener action)

Here you can find the source of createCheckBoxMenuItem(String label, int mnemonic, String description, ItemListener action)

Description

create Check Box Menu Item

License

Open Source License

Declaration

public static JCheckBoxMenuItem createCheckBoxMenuItem(String label, int mnemonic, String description,
            ItemListener action) 

Method Source Code

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

import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.util.EventListener;

import javax.swing.JCheckBoxMenuItem;

import javax.swing.JMenuItem;

public class Main {
    public static JCheckBoxMenuItem createCheckBoxMenuItem(String label, int mnemonic, String description,
            ItemListener action) {
        return createMenuItem(new JCheckBoxMenuItem(label), mnemonic, description, action);
    }/*from  w  ww  .  j a  va 2 s .c om*/

    public static JMenuItem createMenuItem(String label, int mnemonic, String description, ActionListener action) {
        return createMenuItem(new JMenuItem(label), mnemonic, description, action);
    }

    public static <T extends JMenuItem, E extends EventListener> T createMenuItem(T source, int mnemonic,
            String description, E action) {
        source.setMnemonic(mnemonic);
        source.getAccessibleContext().setAccessibleDescription(description);

        if (action instanceof ActionListener) {
            source.addActionListener((ActionListener) action);
        } else if (action instanceof ItemListener) {
            source.addItemListener((ItemListener) action);
        }

        return source;
    }
}

Related

  1. configureJCheckBoxMenuItem( final JCheckBoxMenuItem mi, final Action a)
  2. createCheckBoxMenuItem(final JInternalFrame f)
  3. createCheckBoxMenuItem(final String text, final boolean selected)
  4. createCheckBoxMenuItem(String text, Icon icon, String toolTip, ActionListener... listeners)
  5. createJCheckBoxMenuItem(String name, String command, ActionListener listener, boolean isSelected)
  6. unconfigureJCheckBoxMenuItem(JCheckBoxMenuItem mi, Action a)