List of utility methods to do JMenu
JMenuItem | menuItem(JMenu parent, String label, Object... attrs) Construct a new JMenuItem then add it to an existing JMenu. JMenuItem m = new JMenuItem(label, null); int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); boolean hasMnemonic = false; for (Object x : attrs) { if (x instanceof Character || x instanceof Integer) { int k = (x instanceof Character) ? ((int) ((Character) x)) : ((Integer) x).intValue(); if (k < 0) continue; ... |
void | removeAllSeparators(JMenu menu) Convenience method that calls the method removeAllSeparators(JPopupMenu) with the JPopupMenu of the given menu as parameter. removeAllSeparators(menu.getPopupMenu()); |
void | removeTopAndBottomSeparators(JMenu menu) Convenience method that calls the method removeTopAndBottomSeparators(JPopupMenu) with the JPopupMenu of the given menu as parameter. removeTopAndBottomSeparators(menu.getPopupMenu()); |
void | setChildrenEnabled(JMenu menu, boolean enabled) Set the enabled state of a JMenu and all its children. Component child[] = menu.getMenuComponents(); int num_children = child.length; Component me = menu.getComponent(); if (me instanceof JComponent) { ((JComponent) me).setEnabled(enabled); for (int i = 0; i < num_children; i++) { if (child[i] instanceof JComponent) { ... |
void | tearDownMenu(JMenu menu) Totally rip a menu apart, recursively. Vector<JMenuItem> componentsToRemove = new Vector<JMenuItem>(); for (int i = 0; i < menu.getItemCount(); i++) componentsToRemove.add(menu.getItem(i)); for (JMenuItem c : componentsToRemove) if (c == null) ; else if (c instanceof JMenu) tearDownMenu((JMenu) c); ... |