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

JFileChooser overlapping JMenu results in strange behavior (JMenu disappearing)

XMLWordPrintable

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



      Name: rl43681 Date: 03/12/2004


      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 JMenu has a JMenuItem that creates a JFileChooser dialog, the JMenu exhibits strange behavior when the JFileChooser overlaps the original location of the JMenu. When the JMenu is selected again, trying to select a JMenuItem from it makes the JMenu disappear. Selecting it for the second time results in normal behavior.

      This seems to be regression, since this is not present in java version 1.3.1 (*), and judging the behavior it is related to the (currently closed) bug 4189244.

      ==
      (*) also tested against the following version, resulting in normal behavior.
      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
      ==


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      - Run provided test case
      - Select 'file' from menu
      - Select 'open'
      - 'cancel' the file chooser
      - Repeat this cycle once
      - Select 'file' from menu
      - Select 'open' --> menu disappears

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      menu should not disappear...
      ACTUAL -
      ... but it does

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.event.*;
      import javax.swing.*;

      /**
       * @author Adriaan de Jonge
       * @author Remco de Boer
       */

      public class TestCase implements ActionListener
      {

        private JFrame mainFrame;

        public TestCase()
        {
          JMenuBar menuBar = new JMenuBar();
          JMenu fileMenu = menuBar.add(new JMenu("File"));
          JMenuItem open = fileMenu.add(new JMenuItem("Open"));
          open.addActionListener(this);

          mainFrame = new JFrame("mainFrame");
          mainFrame.setJMenuBar(menuBar);
          mainFrame.pack();
          mainFrame.setBounds(200, 200, 150, 150);
          mainFrame.setVisible(true);
        }

        public static void main(String[] args) throws Exception
        {
          new TestCase();
        }

        public void actionPerformed(ActionEvent arg0)
        {
          JFileChooser fc = new JFileChooser();

          // BUG
          fc.showOpenDialog(mainFrame.getContentPane());

          // Q&D Fix
          //fc.showOpenDialog(null);
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Providing 'null' as argument to the showOpenDialog method seems to prevent this (or at least extends the number of cycles before the bug appears). [see test case]
      (Incident Review ID: 216087)
      ======================================================================

            kizune Alexander Zuev
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: