List of utility methods to do JMenu
boolean | addSeparatorIfNeeded(JMenu menu) Convenience method that calls the method addSeparatorIfNeeded(JPopupMenu) with the JPopupMenu of the given menu as parameter. return addSeparatorIfNeeded(menu.getPopupMenu());
|
void | applyDefaultProperties(final JMenu comp) Sets default background and foreground color as well as a default font for the specified component. if (comp == null) { return; applyProperties(comp, "Menu.background", "Menu.foreground", "Menu.font"); |
void | assignMnemonics(JMenu menu) assign Mnemonics Component[] comps = menu.getMenuComponents(); ArrayList list = new ArrayList(); char mne; for (int count = 0; count < comps.length; count++) { if (comps[count] instanceof JMenuItem) { mne = getMnemonic(((JMenuItem) comps[count]).getText(), list); ((JMenuItem) comps[count]).setMnemonic(mne); |
void | changeMenuItemsState(final JMenu menu, final boolean enableState) change Menu Items State final int size = menu.getItemCount(); for (int i = 0; i < size; i++) { final JMenuItem item = menu.getItem(i); item.setEnabled(enableState); |
void | constructRecentlyFilesMenuItems(JMenu recentlyOpenFilesMenuItem, LinkedHashMap, ?> filesOpenedLHM) To use to construct JMenuItens for recently opened files. recentlyOpenFilesMenuItem.removeAll(); if (filesOpenedLHM.size() == 0) { recentlyOpenFilesMenuItem.setEnabled(false); } else { recentlyOpenFilesMenuItem.setEnabled(true); Iterator<?> it = filesOpenedLHM.keySet().iterator(); while (it.hasNext()) { JMenuItem nMenuItem = (JMenuItem) it.next(); ... |
boolean | containsMenuComponent(JMenu parent, Component comp) contains Menu Component return indexOfMenuComponent(parent, comp) != -1;
|
int | countCheckBoxMenuItem(JMenu menu) count Check Box Menu Item int count = 0; for (int i = 0; i < menu.getMenuComponentCount(); i++) { Component c = menu.getMenuComponent(i); if (c instanceof JCheckBoxMenuItem) { count++; return count; ... |
void | createMenu(String menuText, JMenu menu, ActionListener listener) create Menu menu.add(createMenuItem(menuText, listener)); |
JMenuBar | createMenuBar(JMenu... menues) create Menu Bar JMenuBar menuBar = new JMenuBar(); for (JMenu menu : menues) { menuBar.add(menu); return menuBar; |
JMenuItem | createMenuItem(JMenu parent, String text) create Menu Item JMenuItem mi = new JMenuItem(); configureTextAndMnemonic(mi, text); parent.add(mi); return mi; |