JDK-4471924 : Non-modal JDialog remains visible even after a call to setVisible(false).
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 4.4,4.5,1.3.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux,windows_nt
  • CPU: x86
  • Submitted: 2001-06-19
  • Updated: 2006-01-25
  • Resolved: 2006-01-25
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Name: yyT116575			Date: 06/19/2001


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)

A non-modal JDialog remains visible even after a call to setVisible(false).
This happens when the call to setVisible(false) is made at the time the parent
JFrame has been minimized (iconified) by the user.

/** To duplicate the bug:
 *  0. Compile and run the program below.
 *  1. Hit the "Perform Long Computation" button
 *  2. Minimize (iconify) the application.
 *  3. Wait for 5 seconds (until "computation" is over).
 *  4. Restore (de-iconify) the application window.
 *  5. The "Wait" JDialog is still visible, although
 *     a call to setVisible(false) has been made.
 *  6. This behavior didn't happen on Solaris and Linux platform
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class FrameDemo {
  JFrame mFrame;
  JButton mTestButton;
  JDialog mDialog;

  public FrameDemo() {
    mFrame = new JFrame("FrameDemo");

    mFrame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });

    mFrame.setBounds(200, 200, 400, 200);

    mDialog = new JDialog(mFrame, "Please Wait", false);
    mDialog.setBounds(new Rectangle(300, 250, 200, 100));

    mTestButton = new JButton("Perform Long Computation...");
    mFrame.getContentPane().add(mTestButton, BorderLayout.SOUTH);
    mFrame.setVisible(true);

    mTestButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent f) {
        mDialog.setVisible(true);
        System.out.println("Starting Computation.....");
        try{
          Thread.sleep(5000);
        } catch (Exception e) {
        }
        System.out.println("Finished Computation.");
        mDialog.setVisible(false);
      }
    });
  }

  public static void main(String s[]) {
    FrameDemo f = new FrameDemo();
  }
}
(Review ID: 126905) 
======================================================================

Comments
EVALUATION The XAWT problem is duplicate of 5005454
25-01-2006

EVALUATION The problem was fixd for Windows platform by fix for 4842599 (REGRESSION: JPopupMenu not Hidden Properly After Iconified and Deiconified) Still need to fix it on X/XToolkit
24-01-2006

EVALUATION Reproducible on Windows and X/XToolkit. Not reproducible on X/MToolkit. Windows: Iconifying the window makes it and all its children invisible, so calling ::ShowWindow(hwnd, SW_HIDE) for the dialog does nothing. However, the dialog remains visible and is restored together with its owner frame. X/XToolkit: The source of the problem is quite the same: when the window is iconified, it gets unmapped. Calling setVisible(false) leads to XUnmapWindow(), but it does nothing for already unmapped window. And, again, the dialog is restored with the owner frame. ###@###.### 2005-03-01 16:08:54 GMT
01-03-2005