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

dropped down menu behaves strangely after the containing frame hidden and showed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • client-libs
    • None



      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);
          }
      }

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

            leifs Leif Samuelsson (Inactive)
            son Oleg Sukhodolsky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: