JDK-6660397 : JDialog.setVisible(false) does not work if application is minimized in Gnome
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: solaris_10
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2008-02-07
  • Updated: 2011-01-19
  • Resolved: 2008-04-17
Related Reports
Duplicate :  
Description
ENVIRONMENT
SunOS XXX 5.10 Generic_125100-04 sun4u sparc SUNW,Sun-Fire-V490

java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)

GENERAL DESCRIPTION
Gnome allows to minimize application with open dialog, both modal and non-modal. This can be done via taskbar menu. If an application closes dialog by itself while minimized the dialog is not closed and sometimes cannot be closed even manually.

STEPS TO REPRODUCE
1. Application opens JDialog by calling setVisible(true)
2. Application starts background thread that does some work.
3. The user minimises the application via Gnome taskbar (context menu on application)
4. Background thread closes dialog by calling setVisible(false) (via invokeAndWait)
5. The user restores the application via Gnome taskbar

Dialog should be closed however it's not closed and badly rendered. Sometimes it cannot be closed even by [x] button. If the application is not minimized then all is OK. Please, see source sample below.

SOURCE SAMPLE:


import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

class BugDialog extends JDialog {
    public BugDialog(JFrame parent) {
        super(parent, true);
        
        final JButton button = new JButton("Launch thread");
        button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Thread thread = new Thread() {
                    public void run() {
                        try {
                            // Change button text to show thread is started
                            SwingUtilities.invokeAndWait(new Runnable() {
                                public void run() { button.setText("Thread launches, quickly minimize application"); }
                            });
                            
                            // Just sleep, here could be some real work
                            // Here the user should minimize the application.
                            sleep(10000);
                            
                            // Close the dialog
                            SwingUtilities.invokeAndWait(new Runnable() {
                                public void run() { setVisible(false); }
                            });
                        } catch (Exception e) {}
                    }
                };                
                thread.start();
            }
        });
        add(button);
        setBounds(10, 10, 300, 200);
    }
}

class BugFrame extends JFrame {
    public BugFrame() {
        setTitle("JDialog Bug Test");
        JButton button = new JButton("Open Dialog");
        button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                new BugDialog(BugFrame.this).setVisible(true);
            }
        });
        add(button);
        setBounds(10, 10, 300, 200);
    }
}

public class JDialogBugTest {
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new BugFrame().setVisible(true);
            }
        });        
    }
}

Comments
EVALUATION Reassigned to the friends from AWT who know more about Gnome
10-04-2008