List of utility methods to do JMenu
void | addListenerToItems(JMenu menu, ActionListener listener) add Listener To Items for (int i = 0; i < menu.getItemCount(); i++) { JMenuItem jmi = menu.getItem(i); if (jmi != null) jmi.addActionListener(listener); |
void | addMenuItem(ActionListener al, JMenu m, String label, String command, int key, int ckey) add Menu Item JMenuItem menuItem;
menuItem = new JMenuItem(label);
m.add(menuItem);
menuItem.setActionCommand(command);
menuItem.addActionListener(al);
setKeystroke(menuItem, ckey);
|
JMenuItem | addMenuItem(ActionListener li, JMenu menu, String text, String tip) add a new item to the give menu, add an action listener and set the tool tip JMenuItem mi = new JMenuItem(text); mi.addActionListener(li); mi.setToolTipText(tip); menu.add(mi); return mi; |
JMenuItem | addMenuItem(JMenu menu, Action action) add Menu Item JMenuItem item = menu.add(action);
configureMenuItem(item, action);
return item;
|
JMenuItem | addMenuItem(JMenu menu, String label, Action action, int mnemonic, String tooltip, boolean isEnabled) Add an action to a menu and return the menu item created. if (tooltip == null) { tooltip = (String) action.getValue("tooltip"); } else { action.putValue("tooltip", tooltip); action.putValue("tooltip", tooltip); JMenuItem item = menu.add(action); item.setText(label); ... |
JMenuItem | addMenuItem(JMenu menu, String label, Action action, int mnemonic, String tooltip, boolean isEnabled) Add an action to a menu and return the menu item created. if (tooltip == null) { tooltip = (String) action.getValue("tooltip"); } else { action.putValue("tooltip", tooltip); action.putValue("tooltip", tooltip); JMenuItem item = menu.add(action); item.setText(label); ... |
void | addMenuItem(Window window, JMenu menu, String title, String icon, int mnemonic, KeyStroke key, ActionListener listener) add Menu Item JMenuItem menuItem = new JMenuItem(title, mnemonic); if (key != null) menuItem.setAccelerator(key); if (icon != null) menuItem.setIcon(new ImageIcon(window.getClass().getResource(icon))); if (listener != null) menuItem.addActionListener(listener); menu.add(menuItem); ... |
void | addMenuItems(JMenu menu, JComponent... items) add Menu Items for (JComponent item : items) {
menu.add(item);
|
void | addRadioButtonMenuItem(ActionListener al, JMenu m, String label, String command, boolean b, ButtonGroup g) add Radio Button Menu Item JRadioButtonMenuItem menuItem;
menuItem = new JRadioButtonMenuItem(label);
m.add(menuItem);
menuItem.setActionCommand(command);
menuItem.addActionListener(al);
menuItem.setSelected(b);
g.add(menuItem);
|
void | addSeparator(JMenu menu) add Separator if (menu.getComponentCount() > 0) menu.add(new JSeparator()); |