Java Utililty Methods Swing Menu Item

List of utility methods to do Swing Menu Item

Description

The list of methods to do Swing Menu Item are organized into topic(s).

Method

JMenuItemcreateMenuItem(String caption, Action action)
Create menu item.
JMenuItem menuItem = new JMenuItem(caption);
menuItem.addActionListener(action);
return menuItem;
JMenuItemcreateMenuItem(String menuItemName, ActionListener actionListener)
create Menu Item
JMenuItem menuItem = new JMenuItem(menuItemName);
menuItem.addActionListener(actionListener);
return menuItem;
JMenuItemcreateMenuItem(String menuText, ActionListener listener)
create Menu Item
JMenuItem menuItem = new JMenuItem(menuText);
menuItem.addActionListener(listener);
return menuItem;
JMenuItemcreateMenuitem(String name, ActionListener listener)
create Menuitem
final JMenuItem button = new JMenuItem(name);
button.addActionListener(listener);
return button;
JMenuItemcreateMenuItem(String name, String description, int mnemonic, int accelerator, ActionListener listener)
Makes a new menu item.
JMenuItem item = new JMenuItem(name, mnemonic);
item.getAccessibleContext().setAccessibleDescription(description);
item.setAccelerator(
        KeyStroke.getKeyStroke(accelerator, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
item.addActionListener(listener);
return item;
JMenuItemcreateMenuItem(String strTitle, String strActionCommand, ActionListener alListener)
Create a popup menu item
JMenuItem deleteItem = new JMenuItem();
if (strTitle != null && !strTitle.isEmpty()) {
    deleteItem.setText(strTitle);
if (strActionCommand != null && !strActionCommand.isEmpty()) {
    deleteItem.setActionCommand(strActionCommand);
if (alListener != null) {
...
JMenuItemcreateMenuItem(String text, boolean visible)
create Menu Item
JMenuItem item = new JMenuItem(text);
item.setVisible(visible);
return item;
JMenuItemcreateMenuItem(String text, Icon icon, String toolTip, ActionListener... listeners)
create Menu Item
JMenuItem result = new JMenuItem(text, icon);
if (toolTip != null) {
    result.setToolTipText(toolTip);
for (ActionListener listener : listeners) {
    result.addActionListener(listener);
return result;
...
TcreateMenuItem(T source, int mnemonic, String description, E action)
create Menu Item
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;
...
JRadioButtonMenuItemcreateRadioButtonMenuItem(final String text, final boolean selected)
create Radio Button Menu Item
return new JRadioButtonMenuItem(text, selected);