JDK-4127064 : Heavyweight JPopupMenus obscure other applications
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.5
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 1998-04-08
  • Updated: 1998-04-21
  • Resolved: 1998-04-21
Related Reports
Duplicate :  
Description

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)
======================================================================

Comments
EVALUATION This is just a side effect of the bug that Swing menus do not pop down when you click on other apps (if they popped down as they should, they would not be on top of the other app's windows). georges.saab@Eng 1998-04-20
20-04-1998