List of usage examples for javax.swing JMenu isEnabled
public boolean isEnabled()
From source file:net.sf.jabref.gui.RightClickMenu.java
/** * @param move For add: if true, remove from previous groups */// w w w .ja v a 2s. c o m private void insertNodes(JMenu menu, GroupTreeNode node, BibEntry[] selection, boolean add, boolean move) { final AbstractAction action = getAction(node, selection, add, move); if (node.getChildCount() == 0) { JMenuItem menuItem = new JMenuItem(action); setGroupFontAndIcon(menuItem, node.getGroup()); menu.add(menuItem); if (action.isEnabled()) { menu.setEnabled(true); } return; } JMenu submenu; if (node.getGroup() instanceof AllEntriesGroup) { for (int i = 0; i < node.getChildCount(); ++i) { insertNodes(menu, (GroupTreeNode) node.getChildAt(i), selection, add, move); } } else { submenu = new JMenu('[' + node.getGroup().getName() + ']'); setGroupFontAndIcon(submenu, node.getGroup()); // setEnabled(true) is done above/below if at least one menu // entry (item or submenu) is enabled submenu.setEnabled(action.isEnabled()); JMenuItem menuItem = new JMenuItem(action); setGroupFontAndIcon(menuItem, node.getGroup()); submenu.add(menuItem); submenu.add(new Separator()); for (int i = 0; i < node.getChildCount(); ++i) { insertNodes(submenu, (GroupTreeNode) node.getChildAt(i), selection, add, move); } menu.add(submenu); if (submenu.isEnabled()) { menu.setEnabled(true); } } }
From source file:net.sf.jabref.gui.ImportInspectionDialog.java
private void insertNodes(JMenu menu, GroupTreeNode node) { final AbstractAction action = getAction(node); if (node.getNumberOfChildren() == 0) { menu.add(action);/*from w w w . j a v a2 s .c o m*/ if (action.isEnabled()) { menu.setEnabled(true); } return; } JMenu submenu; if (node.getGroup() instanceof AllEntriesGroup) { for (GroupTreeNode child : node.getChildren()) { insertNodes(menu, child); } } else { submenu = new JMenu('[' + node.getName() + ']'); // setEnabled(true) is done above/below if at least one menu // entry (item or submenu) is enabled submenu.setEnabled(action.isEnabled()); submenu.add(action); submenu.add(new JPopupMenu.Separator()); for (GroupTreeNode child : node.getChildren()) { insertNodes(submenu, child); } menu.add(submenu); if (submenu.isEnabled()) { menu.setEnabled(true); } } }