Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6897701

In Nimbus Disabled Menus and Menu Items don't look disabled

XMLWordPrintable

    • 6
    • b116
    • x86
    • windows_xp

      ava version "1.6.0_16"
      Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
      Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)

      Does this problem occur on J2SE 5.0.x or 6.0? Yes / No (pick one)
      Yes

      Operating System Configuration Information (be specific):
      Client: Microsoft Windows XP [Version 5.1.2600]

      Bug Description:
      In Nimbus Disabled Menus and Menu Items don't look disabled

      The other 4 Look and Feels look fine.
      For Nimbus though every time we enable or disable a menu item, we also need to go and change its color, which does not appear to be the intended behavior.

      Expected: 'Disabled Menu' and 'Disabled Menu Item' to appear disabled (as with the other 4 Look and Feels)
      Actual: They appear enabled

      import static java.awt.Color.*;;
      import static javax.swing.JFrame.*;
      import javax.swing.*;

      public class Test {
        public static void main(String[] args) throws Exception {
          //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
          UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
          //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
          //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
          //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");

          JMenuItem enabledMenuItem = new JMenuItem("Enabled Menu Item");
          enabledMenuItem.setForeground(BLUE);
          JMenuItem disabledMenuItem = new JMenuItem("Disabled Menu Item");
          disabledMenuItem.setForeground(BLUE);
          disabledMenuItem.setEnabled(false);
          JMenu enabledMenu = new JMenu("Enabled Menu");
          enabledMenu.setForeground(BLUE);
          enabledMenu.add(enabledMenuItem);
          enabledMenu.add(disabledMenuItem);
          JMenu disabledMenu = new JMenu("Disabled Menu");
          disabledMenu.setForeground(BLUE);
          disabledMenu.setEnabled(false);
          JMenuBar menuBar = new JMenuBar();
          menuBar.add(enabledMenu);
          menuBar.add(disabledMenu);
          JFrame frame = new JFrame();
          frame.setJMenuBar(menuBar);
          frame.pack();
          frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
          frame.setVisible(true);
        }
      }

            pkbalakr Prem Balakrishnan (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: