JDK-4368295 : dropped down menu behaves strangely after the containing frame hidden and showed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2000-09-05
  • Updated: 2000-10-24
  • Resolved: 2000-10-24
Related Reports
Duplicate :  
Description

Name: osR10079			Date: 09/05/2000

dropped down menu behaves strangely after the containing
frame hidden and showed again.
Run the test. Menu will be in a strange state: dropped down, but when
we move mouse over it, menu items won't be hightlighted, and when we
press a menu item, menu won't close, though ActionEvents still will be
delivered.  This behavior will continue until the menu will be pressed.

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

public class Menu {
    public static void main (String[] args) {
        ActionListener al = new ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    System.out.println("actionPerformed");
                }
            };
        JMenuItem jmi;
        JMenuBar jmb = new JMenuBar();
        JMenu jm = new JMenu("File");
        jm.add(jmi = new JMenuItem ("Save"));
        jmi.addActionListener(al);
        jm.add(jmi = new JMenuItem ("Open"));
        jmi.addActionListener(al);
        jmb.add(jm);
        JFrame jf = new JFrame("Test");
        jf.setJMenuBar(jmb);
        jf.setSize(200, 200);
        jf.setVisible(true);
        jm.doClick(1);
        try { Thread.sleep(500); } catch (InterruptedException ie) {}
        jf.setVisible(false);
        jf.setVisible(true);
    }
}

======================================================================