// -----------stops listeners and reestablish blocked menues----------- private void shutDownEverything() { this.removeMouseListener(mouseListener); this.removeMouseMotionListener(mouseListener); menuBar.getMenu(0).getMenuComponent(0).setEnabled(false); // keep everything disable (for now) menuBar.getMenu(0).getMenuComponent(1).setEnabled(false); }
/** * Fired by a view when the figure seleciton changes. Since Commands and Tools are Actions and * they are registered to hear these events, they will handle themselves. So selection sensitive * menuitems will update their own states. * * @see DrawingEditor */ public void figureSelectionChanged(DrawingView view) { JMenuBar mb = getJMenuBar(); CommandMenu editMenu = (CommandMenu) mb.getMenu(EDIT_MENU); // make sure it does exist if (editMenu != null) { editMenu.checkEnabled(); } CommandMenu alignmentMenu = (CommandMenu) mb.getMenu(ALIGNMENT_MENU); // make sure it does exist if (alignmentMenu != null) { alignmentMenu.checkEnabled(); } JMenu attributeMenu = mb.getMenu(ATTRIBUTES_MENU); // make sure it does exist if (attributeMenu != null) { for (int i = 0; i < attributeMenu.getItemCount(); i++) { JMenuItem currentMenu = attributeMenu.getItem(i); if (currentMenu instanceof CommandMenu) { ((CommandMenu) currentMenu).checkEnabled(); } } } }