List of utility methods to do JMenuBar
void | addFastKeys(JMenuBar menuBar) add Fast Keys for (Component menuComponent : menuBar.getComponents()) { JMenu menu = (JMenu) menuComponent; menu.setMnemonic(menu.getText().charAt(menu.getText().indexOf('&') + 1)); menu.setText(menu.getText().replace("&", "")); for (Component menuItemComponent : menu.getMenuComponents()) if (menuItemComponent instanceof JMenuItem) { JMenuItem menuItem = (JMenuItem) menuItemComponent; menuItem.setMnemonic(menuItem.getText().charAt(menuItem.getText().indexOf('&') + 1)); ... |
void | addMenuItems(JMenuBar menu, JComponent... items) add Menu Items for (JComponent item : items) {
menu.add(item);
|
void | applyDefaultProperties(final JMenuBar comp) Sets default background and foreground color as well as a default font for the specified component. if (comp == null) { return; applyProperties(comp, "MenuBar.background", "MenuBar.foreground", "MenuBar.font"); |
JMenuBar | cloneMenuBar(final JMenuBar menubar) Creates a copy of this menu bar, whose contents update automatically whenever the original menu bar changes. if (menubar == null) return null; final JMenuBar jmb = new JMenuBar(); final int count = menubar.getMenuCount(); for (int i = 0; i < count; i++) jmb.add(cloneMenuItem(menubar.getMenu(i))); return jmb; |
JMenu | createMenuInMenuBar(final JMenuBar menuBar, final String menuName) Adds a menu to the specified menu bar. final JMenu menu = new JMenu(); menu.setText(menuName); menuBar.add(menu); return menu; |
JMenuItem | findItem(JMenuBar menuBar, String menuName, String menuItemName) find Item Component component = findMenuComponent(menuBar, menuName, menuItemName); return component instanceof JMenuItem ? (JMenuItem) component : null; |
JMenu | findMenu(JMenuBar bar, Class extends JMenu> type) find Menu if (bar != null) { int count = bar.getMenuCount(); for (int i = 0; i < count; i++) { JMenu menu = bar.getMenu(i); if (type.isInstance(menu)) { return menu; return null; |
JMenu | findMenu(JMenuBar menuBar, String menuName) find Menu MenuElement[] menus = menuBar.getSubElements(); for (int ii = 0; ii < menus.length; ++ii) { JMenu menu = (JMenu) menus[ii].getComponent(); if (menu.getText().equals(menuName)) return menu; return null; |
JMenu | findMenu(JMenuBar menuBar, String menuName, String subMenuName) find Menu Component component = findMenuComponent(menuBar, menuName, subMenuName); return component instanceof JMenu ? (JMenu) component : null; |
JMenu | findMenu(JMenuBar menuBar, String name, boolean deepSearch) find Menu int n = menuBar.getMenuCount(); for (int i = 0; i < n; i++) { JMenu menu = menuBar.getMenu(i); if (name.equals(menu.getName())) { return menu; if (deepSearch) { ... |