List of utility methods to do JMenu
void | fixJMenuBug() Call the following two methods to avoid that JMenu's are rendered behind ElementDataView canvas. JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); |
JMenuItem | getMenu(JMenu poMenu, String psComando, boolean pbRecurs) Devuelve el submenu que tiene el actioncomand psComando JMenuItem loResult = null; for (int i = 0; i < poMenu.getMenuComponentCount() && loResult == null; i++) { Component loElem = poMenu.getMenuComponent(i); if (loElem instanceof JMenuItem) { JMenuItem loMenu = (JMenuItem) loElem; if (loMenu.getActionCommand().equals(psComando)) { loResult = loMenu; } else { ... |
JMenuItem | getMenuItem(JMenu menu, String text) get Menu Item for (Component c : menu.getMenuComponents()) { if (c instanceof JMenu) { JMenuItem m = getMenuItem((JMenu) c, text); if (m != null) return m; } else if (c instanceof JMenuItem && ((JMenuItem) c).getText().equals(text)) { return (JMenuItem) c; return null; |
int | getMenuItemIndex(JMenu menu, String menuItemText) get Menu Item Index int theIdx = -1; for (int i = 0; i < menu.getMenuComponentCount(); i++) { Component c = menu.getMenuComponent(i); if (c instanceof JMenuItem) { JMenuItem mi = (JMenuItem) c; if (mi.getText().equals(menuItemText)) { theIdx = i; i = menu.getMenuComponentCount(); ... |
JMenuItem[] | getMenuItems(JMenu menu) get Menu Items JMenuItem[] result = new JMenuItem[menu.getItemCount()]; for (int i = 0; i < result.length; i++) { result[i] = menu.getItem(i); return result; |
Map | getTextByJMenu(List get the text of menus from a given list of menus Map<String, Integer> mpMenus = new HashMap<String, Integer>(); for (int i = 0; i < lstMenus.size(); i++) mpMenus.put(lstMenus.get(i).getText(), i); return mpMenus; |
boolean | insertSeparatorIfNeeded(JMenu menu, int position) Convenience method that calls the method insertSeparatorIfNeeded(JPopupMenu,int) with the JPopupMenu of the given menu as the first parameter and with the given position as second parameter. return insertSeparatorIfNeeded(menu.getPopupMenu(), position);
|
boolean | isAtLeastOneChildComponentVisible(JMenu menu) Convenience method that calls the method isAtLeastOneChildComponentVisible(Container) with the JPopupMenu of the given menu as parameter. return isAtLeastOneChildComponentVisible(menu.getPopupMenu());
|
void | limitMenuSize(JMenu menu, String name, int size) This ensures that there are no more than size number of items in any sub menu. limitMenuSize(menu, name, size, true); |
JMenu | makeMenu(JMenu menu, List menuItems) Create a JMenu and add the menus contained with the menus list If no menus then return null. if (menuItems == null) { return menu; for (int i = 0; i < menuItems.size(); i++) { Object o = menuItems.get(i); if (o.toString().equals(MENU_SEPARATOR)) { menu.addSeparator(); } else if (o instanceof JMenuItem) { ... |