private JMenu getSubmenu(String name) { return getSubmenu(name, -1); }
protected void setSubMenuIcon(String name, ImageIcon icon) { getSubmenu(name, -1).setIcon(icon); }
protected void addCheckboxItem(String action, String text, String parent, boolean selected) { if (parent != null) { JMenuItem item = makeCheckboxItem(action, text, selected); getSubmenu(parent).add(item); items.put(action, item); } else { addCheckboxItem(action, text, selected); } }
protected void addRadioItem(String action, String text, String group, String parent) { if (parent != null) { JMenuItem item = makeRadioItem(action, text, group); getSubmenu(parent).add(item); items.put(action, item); } else { addRadioItem(action, text, group); } }
/** * Adds a seperator to the submenu with the given name, or adds a seperator * in the main menu if this submenu doesn't exist yet. * * @param parent */ protected void addSeparator(int pos, String parent) { if (parent != null && isSubmenu(parent)) { if (pos > -1) { getSubmenu(parent).insertSeparator(pos); } else { getSubmenu(parent).addSeparator(); } } else { if (pos > -1) { insert(new Separator(), pos); } else { addSeparator(); } } }
JMenuItem item = makeItem(action, text, icon); if (pos > -1) { getSubmenu(parent).insert(item, pos); } else { getSubmenu(parent).add(item);
public JMenuItem addCommandItem(CommandMenuItem item) { if (item.getCommand() == null && item.getLabel() == null) { addSeparator(item.getPos(), item.getParent()); } else if (item.getCommand() == null) { JMenu menu = getSubmenu(item.getLabel(), item.getPos()); addKey(item, menu); } else { commands.put(item.getId(), item.getCommand()); JMenuItem mItem = addItem(item.getId(), item.getLabel(), item.getPos(), item.getParent(), null); addKey(item, mItem); } return null; }