List of utility methods to do Swing Menu
boolean | isMenuCrossMenuMnemonics() is Menu Cross Menu Mnemonics return UIManager.getBoolean("Menu.crossMenuMnemonic"); |
void | limitMenuSize(List items, String name, int size) This takes the list of JMenuItems and, for each JMenu, will ensure that there are no more than size number of items in any sub menu. for (int i = 0; i < items.size(); i++) { Object o = items.get(i); if (!(o instanceof JMenu)) { continue; JMenu menu = (JMenu) o; limitMenuSize(menu, name, size); |
JMenuBar | makeMenuBar(List menus) Create a JMenuBar and add the menus contained with the menus list If no menus then return null. if ((menus == null) || (menus.size() == 0)) { return null; JMenuBar menuBar = new JMenuBar(); for (int i = 0; i < menus.size(); i++) { menuBar.add((JMenu) menus.get(i)); return menuBar; ... |
void | makeMenubarNice() Optimizes the appeareance of the JMenubar. UIManager.put("MenuBar.border", getEtchedBottomBorder(0, 2));
|
KeyStroke | menuDigit(int digit) menu Digit if (digit < 0 || digit > 9) throw new IllegalArgumentException("Not a digit: " + digit); return menuKeystroke(KeyEvent.VK_0 + digit); |
KeyStroke | menuKeystroke(int virtualKey) menu Keystroke return KeyStroke.getKeyStroke(virtualKey, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
|
void | removeMenuMnemonics(MenuElement[] elements) Remove the menu shortcut Mnemonics from the given MenuElement and its sub MenuElements. for (int i = 0; i < elements.length; i++) { MenuElement element = elements[i]; if (element instanceof JMenuItem) { JMenuItem item = (JMenuItem) element; item.setMnemonic(-1); removeMenuMnemonics(element.getSubElements()); |
void | setFontsToMenu(MenuElement menuElement, Font font) set Fonts To Menu MenuElement[] subElements = menuElement.getSubElements(); menuElement.getComponent().setFont(font); menuElement.getComponent().invalidate(); if (subElements == null) return; for (int i = 0; i < subElements.length; i++) setFontsToMenu(subElements[i], font); |
void | setMenuFont(Object item, Font theFont) set Menu Font if (item instanceof JMenu) { JMenu menu = (JMenu) item; menu.setFont(theFont); for (int j = 0; j < menu.getItemCount(); j++) { if (menu.getItem(j) != null) { setMenuFont(menu.getItem(j), theFont); } else { JMenuItem menuItem = (JMenuItem) item; menuItem.setFont(theFont); for (int i = 0; i < menuItem.getSubElements().length; i++) { setMenuFont((JMenuItem) menuItem.getSubElements()[i], theFont); |
void | setMenuText(AbstractButton item, String text, boolean useMnemonic) DOCUMENT ME! int i = text.indexOf('&'); if (i < 0) { item.setText(text); } else { item.setText(text.substring(0, i) + text.substring(i + 1)); if (useMnemonic) { item.setMnemonic(text.charAt(i + 1)); |