Here you can find the source of createCheckBoxMenuItem(String label, int mnemonic, String description, ItemListener action)
public static JCheckBoxMenuItem createCheckBoxMenuItem(String label, int mnemonic, String description, ItemListener action)
//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; } }