Пример #1
0
  /**
   * This package-private method is called by JMenuwhen this JMenu is added to it as a submenu. It
   * is not intended to be called by application programmers.
   */
  void setParentMenu(Component parent_) {
    _parentMenu = new WeakReference<Component>(parent_);

    // If the colors of this menu have not been set yet, inherit the
    // colors of the parent.
    if (super.getForeground() == null) super.setForeground(parent_.getForeground());

    if (super.getBackground() == null) super.setBackground(parent_.getBackground());
  }
Пример #2
0
  /**
   * Sets the background color of this JMenu and all its contained JMenuItems that do not yet have
   * their background color set. Overrides the same method in the Component class.
   */
  public void setBackground(Color color_) {
    super.setBackground(color_);

    Enumeration<Component> e = _menuItems.elements();
    while (e.hasMoreElements()) {
      Component c = e.nextElement();
      if (c.getBackground() == null) c.setBackground(color_);
    }
  }