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

Modal dialog causes underlying parent JFrame to be set to "Always on top".

XMLWordPrintable

    • b116
    • x86
    • windows_xp
    • Verified

      FULL PRODUCT VERSION :
      JRE 6 update 12_b04

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP PRofessional
      Version 2002
      Service Pack 3

      A DESCRIPTION OF THE PROBLEM :
      I'm having issue with the jre 6 update 12 with our Swing application. It works fine with update 11. The issue is that my JFrame is somehow getting set to be "always on top" once I've opened an closed a modal dialog from that JFrame.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Here is the steps:

      1) Open a JFrame (note the "alwaysOnTop" is not set to true).
      2) Click on a button which will open a modal dialog.
      3) While the dialog is open click on the underlying JFrame (nothing happens as modal dialog is blocking it).
      4) Now close the dialog and suddenly the parent JFrame is now set to be always on top. This won't happen if I didn't click on the parent JFrame while the dialog was open.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect the underlying parent JFrame to not be set to be "always on top".
      ACTUAL -
      The parent JFrame is set to be "always on top"/

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class TestTool {

          /**
           * Main.
           *
           * @param args Input arguments.
           */
          public static void main(String[] args) {
              final JFrame f = new JFrame();
              
              JButton open = new JButton("Open Dialog");
                     
              JLabel lb1 = new JLabel(
               "<html>" +
                      "<ul> " +
                      "Recreate always on top bug" +
               "<li>Click on \"Open Dialog\" button</li>" +
               "<li>Click on parent frame while the dialog is open</li>" +
               "<li>Close the dialog</li>" +
               "<li>Frame is now set to be always on top</li>" +
               "</ul>" +
               "</html>");
              lb1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
                              
              JPanel bp = new JPanel(new FlowLayout());
              bp.add(open);
              
              Box vBox = Box.createVerticalBox();
              vBox.add(lb1);
              
              open.addActionListener(new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent arg0) {
                      JOptionPane dp = new JOptionPane("Here I am.. ");
                      JDialog jdg = dp.createDialog(f, "Dialog");
                      jdg.setAlwaysOnTop(true);
                      jdg.setLocationRelativeTo(f);
                      jdg.setVisible(true);
                      
                      jdg.dispose();
                  }
              });
              
              Container cont = f.getContentPane();
              cont.setLayout(new BorderLayout());
              cont.add(vBox, BorderLayout.CENTER);
              cont.add(bp, BorderLayout.SOUTH);
              SwingUtilities.invokeLater(new Runnable() {
                 public void run() {
                     f.pack();
                     f.setSize(new Dimension(300, 300));
                     f.setLocationByPlatform(true);
                     f.setVisible(true);
                 }
              });
          }

      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      There is no workaround.

      Release Regression From : 6u11
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            art Artem Ananiev (Inactive)
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: