Пример #1
0
 /**
  * Creates the attributes menu and its submenus. Clients override this method to add additional
  * menu items.
  */
 protected JMenu createAttributesMenu() {
   JMenu menu = new JMenu("Attributes");
   menu.add(createColorMenu("Fill Color", "FillColor"));
   menu.add(createColorMenu("Pen Color", "FrameColor"));
   menu.add(createArrowMenu());
   menu.addSeparator();
   menu.add(createFontMenu());
   menu.add(createFontSizeMenu());
   menu.add(createFontStyleMenu());
   menu.add(createColorMenu("Text Color", "TextColor"));
   return menu;
 }
Пример #2
0
  /**
   * 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();
        }
      }
    }
  }