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

Popup menus do not honor the opaque property

XMLWordPrintable

    • beta
    • x86
    • windows_xp

      When a non-opaque popup menu is shown, the opaque property is not honored. In the following example, the menu items and the popup menu containing these items are made non-opaque. Therefore, the red background should shine through.

      =====START test.java=====
      import javax.swing.*;
      import javax.swing.event.*;

      public class test {
        public static void main(String[] args) {
          JFrame f = new JFrame("Popup Menus");
          f.getContentPane().setBackground(java.awt.Color.RED);

          JMenuBar bar = new JMenuBar();
          JMenu menu;
          JMenuItem item;
          
          bar.add(menu = new JMenu("File"));
          menu.add(item = new JMenuItem("New"));
          item.setOpaque(false);
          menu.add(item = new JMenuItem("Open..."));
          item.setOpaque(false);
          menu.add(item = new JMenuItem("Save"));
          item.setOpaque(false);
          menu.add(item = new JMenuItem("Save As..."));
          item.setOpaque(false);
          f.setJMenuBar(bar);
          
          menu.getPopupMenu().setOpaque(false);

          f.setSize(new java.awt.Dimension(640, 480));
          f.setVisible(true);
        }
      }
      ====END test.java====
      ###@###.### 2005-05-25 18:22:19 GMT

            gromainsunw Guy Romain (Inactive)
            gromainsunw Guy Romain (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: