List of utility methods to do Swing Menu Item
JMenuItem | faqMenuItem() faq Menu Item JMenuItem menu_item = new JMenuItem("Frequently Asked Questions"); menu_item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JOptionPane.showMessageDialog(null, "Add a gap - hold down the shift key and left mouse button; drag the mouse to the right\n" + "Remove a gap - hold down the shift key and left mouse button; drag the mouse to the left\n" + "Zoom in - hold down the right mouse button and drag it to the right\n" + "Zoom out - hold down the right mouse button and drag it to the left\n" ... |
JMenuItem | findMenuItem(Container container, String[] path) Traverse a container hierarchy and returns the JMenuItem with the given path if (path.length == 0) return null; MenuElement currentItem = findMenuBar(container); if (currentItem == null) return null; for (int i = 0; i < path.length; i++) { currentItem = findMenuItem(currentItem, path[i]); if (currentItem == null) ... |
JMenuItem | getExitMenuItem() get Exit Menu Item return exitMenuItem;
|
AbstractButton | getMenuItem(Container container, Action action) Recursively search the contents of the container to find a MenuItem or Button that uses this action. for (int i = 0; i < container.getComponentCount(); i++) { Component item = container.getComponent(i); if (item instanceof AbstractButton && ((AbstractButton) item).getAction().equals(action)) { return (AbstractButton) item; } else if (item instanceof Container) { return getMenuItem((Container) item, action); return null; |
JMenuItem | getMenuItem(Container owner, String text) get Menu Item return (JMenuItem) getAbstractButton(owner, text);
|
Border | getMenuItemBorder() get Menu Item Border return new EmptyBorder(1, 10, 1, 10); |
Object | getMenuItemDisabledForegroundObject() get Menu Item Disabled Foreground Object return UIManager.get("MenuItem.disabledForeground"); |
JComponent | getMenuItemParent() get Menu Item Parent return miParent;
|
JMenuItem | getResetAppSettingsMenuItem() get Reset App Settings Menu Item return ResetAppSettingsMenuItem;
|
SynthContext | getSynthContext(final MenuItemUI ui, final JComponent item) get Synth Context try { final Method getContext = ui.getClass().getMethod("getContext", JComponent.class); getContext.setAccessible(true); return (SynthContext) getContext.invoke(ui, item); } catch (Exception e) { throw new RuntimeException(e); |