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

Medium weight submenus hidden by heavyweight Canvas

    XMLWordPrintable

Details

    • 1.2.2
    • generic, x86, sparc
    • generic, solaris_2.6, windows_nt

    Description



      Name: rk38400 Date: 11/10/98


      /*
      Try this. The medium weight submenus are hidden
      by the heavyweight Canvas.
      */

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class MenuBug extends JFrame {

      public MenuBug() {

      // for Medium Weight menus
      JPopupMenu.setDefaultLightWeightPopupEnabled(false);

      // Create the menus
      JMenuBar menuBar = new JMenuBar();
      JMenu fileMenu = new JMenu("File");
      menuBar.add(fileMenu);
      JMenu sm;
      fileMenu.add(new JMenuItem("New"));
      fileMenu.add(new JMenuItem("Open"));
      fileMenu.add(new JMenuItem("Save"));
      fileMenu.add(sm = new JMenu("Save As..."));

      // these guys don't show up
      sm.add(new JMenuItem("This"));
      sm.add(new JMenuItem("That"));

      // Enable exiting.
      JMenuItem fileExit = new JMenuItem("Exit");
      fileExit.addActionListener(FILE_EXIT_ACTION);
      fileMenu.add(fileExit);

      setJMenuBar(menuBar);

      addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent evt)
      {
      System.exit(0);
      }
      });

      // Create a panel containing a blue canvas
      JPanel p = new JPanel(new BorderLayout());
      Canvas field = new Canvas();
      field.setBackground(Color.blue);

      p.add(field, BorderLayout.CENTER);
      getContentPane().add(p);

      setSize(400,400);
      setVisible(true);

      }

      public static void main(String[] args) {
      new MenuBug();
      }

      public AbstractAction FILE_EXIT_ACTION =
      new AbstractAction("Exit") {
      public void actionPerformed(ActionEvent e) {
      System.exit(0);
      }
      };

      }
      (Review ID: 42331)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              gsaab Georges Saab
              rkarsunw Ralph Kar (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: