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

Heavyweight JPopupMenus obscure other applications

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.5
    • client-libs



      Name: rk38400 Date: 04/08/98


      import java.awt.BorderLayout;
      import java.awt.Panel;
      import java.awt.event.*;
      import com.sun.java.swing.*;
       
      /** On Solaris Sparc 2.6, HeavyWeight JPopupMenus obscure other windows.
        *
        * Step 1: Run the Application.
        * Step 2: Adjust the main window size so that Menu 2 is NOT
        * contained by the main window.
        * Step 3: Click on Menu 2 and move your mouse to another part
        * of the screen, leaving Menu 2 up. Move another
        * window (a terminal window or something) over this
        * application. Note that the Menu 2 window is ON TOP
        * of your terminal emulator.
        *
        * Solsparc 2.6 CDE; JDK 1.1.5; Swing 1.0.1
        * ###@###.###
        */
      class Menu2 extends JFrame implements ActionListener
      {
              Menu2()
              {
                      // use MediumWeight instead of LightWeight
                      JPopupMenu.setDefaultLightWeightPopupEnabled(false);
       
                      JMenuBar mb = new JMenuBar();
                      setJMenuBar(mb);
       
                      JMenu menu = new JMenu("Menu 1");
                      mb.add(menu);
                      menu.setMnemonic('1');
                      for (int i = 3 ; i < 6 ; i++)
                      {
                              addMenuItem(menu, i);
                      }
       
                      menu = new JMenu("Menu 2");
                      mb.add(menu);
                      menu.setMnemonic('2');
                      for (int i = 6 ; i < 15 ; i++)
                      {
                              addMenuItem(menu, i);
                      }
       
                      getContentPane().add(new JTextField("takes up space"));
              }
       
              private void addMenuItem(JMenu menu, int i)
              {
                      JMenuItem item = new JMenuItem("MenuItem " + i);
                      menu.add(item);
       
                      item.addActionListener(this);
                      item.setMnemonic('0' + i);
                      item.setAccelerator(
                              KeyStroke.getKeyStroke((char)(KeyEvent.VK_A + i),
                                                              KeyEvent.ALT_MASK));
              }
       
              public void actionPerformed(ActionEvent e)
              {
                      System.out.println(e.getActionCommand());
              }
       
              public static void main(String args[])
              {
                      JFrame test = new Menu2();
                      test.pack();
                      test.show();
              }
      }
      (Review ID: 26739)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: