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

1.4 REGRESSION: Menu vanishes before menu item can be selected

XMLWordPrintable

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



      Name: jk109818 Date: 09/09/2003


      FULL PRODUCT VERSION :
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

      FULL OS VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      When a menu is clicked after dismissing a modal dialog, the menu pops up, but vanishes before a menu item can be selected. Run my test case under Windows XP and follow the instruction that it gives you.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run my sample testcase. Select the "File->Select..." menu item.
      A dialog will pop up with a single button. Press that button, then
      you will see another dialog pop up. Press "OK" on the second dialog. This
      will dismiss both dialogs. Then click the "File" menu again (releasing the
      mouse). The menu pops up as expected. Now attempt to select an item. It
      will vanish before an item can be selected.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect that once a menu is clicked, it should stay up long enough for a menu item to be selected.
      ACTUAL -
      The menu is displayed after it is clicked, but vanishes before a menu item can be selected.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      import javax.swing.JButton;
      import javax.swing.JDialog;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JMenu;
      import javax.swing.JMenuBar;
      import javax.swing.JMenuItem;
      import javax.swing.JOptionPane;

      /**
       * This class demonstrates a bug in the Windows XP look-and-feel
       * which causes a menu to vanish when selected immediately
       * after a popup dialog is dismissed.
       */
      public class MenuBug {

          public static void main(String[] args) {
              final JFrame f = new JFrame("Menu bug test");
              JMenu menu = new JMenu("File");
              JMenuBar menuBar = new JMenuBar();
              menuBar.add(new JMenu("ignore"));
              menuBar.add(menu);
              for (int i = 0; i < 15; i++){
                  menu.add(new JMenuItem(i+""));
              }

              JMenuItem item = new JMenuItem("Select...");
              menu.add(item);
              item.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e){
                      final JDialog d = new JDialog(f,"Dialog");
                      JButton button = new JButton("Press here");
                      d.getContentPane().add(button);
                      d.setSize(300,200);
                      d.setModal(true);
                      button.addActionListener(
                          new ActionListener(){
                              public void actionPerformed(ActionEvent event){
                      JOptionPane.showMessageDialog(f,
                              "<html>Press \"OK\" then click the File menu to display it."+
                              "<br>(releasing the mouse)." +
                              "<br>Then attempt to select an item."+
                              "<br>You will see that the File menu vanishes before you can"+
                              "<br>make a selection"+
                              "<br><br>If it doesn't fail the first time, it will fail the second.");
                              d.setVisible(false);
                              }
                          });
                      d.show();
                  }
              });
              f.setJMenuBar(menuBar);
              f.getContentPane().add(new JLabel("Select \"File->Select...\" menu item to demonstrate bug."));
              f.pack();
              f.setSize(400,300);
              f.show();
              
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      When selecting the menu, don't release the mouse, or else click it twice.

      Release Regression From : 1.3.1_08
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 189931)
      ======================================================================

            kizune Alexander Zuev
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: