-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
5.0
Name: gm110360 Date: 09/30/2004
FULL PRODUCT VERSION :
java version "1.5.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux 2.4.22-1.2199.nptl i686 athlon i386 GNU/Linux (RedHat Fedora Core 1)
A DESCRIPTION OF THE PROBLEM :
When you show a non-modal JDialog via setVisible(true) and directly a hide via setVisible(false), the dialog is not removed from the screen.
This happens in our case when we show a progress dialog, do some work, and hide the progress dialog again. When the work is done within, say, 10 milliseconds the dialog stays on the screen.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run test program. Click on the button. Multiple dialogs are created, shown and hidden.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No dialogs should be on the screen after the test.
ACTUAL -
Some dialogs are still on the screen after the test has run.
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame implements ActionListener
{
private int delay = 20;
private int loopDelay = 50;
private int xx;
private int x;
private int y;
public Test()
{
JButton button = new JButton("Test JDialog");
button.setActionCommand("test");
button.addActionListener(this);
getContentPane().add(button, BorderLayout.NORTH);
setSize(new Dimension(400, 100));
}
public void actionPerformed(ActionEvent e)
{
if ("test".equals(e.getActionCommand()))
{
xx+=50;
x = xx;
y = 0;
for (int i = 0; i < 100; i++)
{
System.out.println("Showing dialog with delay " + delay);
JDialog dialog = new JDialog(this, "Test Dialog", false);
dialog.setLocation(x, y);
dialog.setVisible(true);
try
{
Thread.sleep(delay);
}
catch (Exception exc) { }
dialog.setVisible(false);
x+=5;
y+=5;
delay -= 5;
if (delay < 0)
delay = 20;
try
{
Thread.sleep(loopDelay);
}
catch (Exception exc) { }
}
}
}
private static void createAndShowGUI()
{
Test test = new Test();
test.setVisible(true);
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(
new Runnable()
{
public void run()
{
createAndShowGUI();
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Delay the setVisible(false) with ~50 milliseconds.
Release Regression From : 1.4.2
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: 315884)
======================================================================
FULL PRODUCT VERSION :
java version "1.5.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux 2.4.22-1.2199.nptl i686 athlon i386 GNU/Linux (RedHat Fedora Core 1)
A DESCRIPTION OF THE PROBLEM :
When you show a non-modal JDialog via setVisible(true) and directly a hide via setVisible(false), the dialog is not removed from the screen.
This happens in our case when we show a progress dialog, do some work, and hide the progress dialog again. When the work is done within, say, 10 milliseconds the dialog stays on the screen.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run test program. Click on the button. Multiple dialogs are created, shown and hidden.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No dialogs should be on the screen after the test.
ACTUAL -
Some dialogs are still on the screen after the test has run.
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame implements ActionListener
{
private int delay = 20;
private int loopDelay = 50;
private int xx;
private int x;
private int y;
public Test()
{
JButton button = new JButton("Test JDialog");
button.setActionCommand("test");
button.addActionListener(this);
getContentPane().add(button, BorderLayout.NORTH);
setSize(new Dimension(400, 100));
}
public void actionPerformed(ActionEvent e)
{
if ("test".equals(e.getActionCommand()))
{
xx+=50;
x = xx;
y = 0;
for (int i = 0; i < 100; i++)
{
System.out.println("Showing dialog with delay " + delay);
JDialog dialog = new JDialog(this, "Test Dialog", false);
dialog.setLocation(x, y);
dialog.setVisible(true);
try
{
Thread.sleep(delay);
}
catch (Exception exc) { }
dialog.setVisible(false);
x+=5;
y+=5;
delay -= 5;
if (delay < 0)
delay = 20;
try
{
Thread.sleep(loopDelay);
}
catch (Exception exc) { }
}
}
}
private static void createAndShowGUI()
{
Test test = new Test();
test.setVisible(true);
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(
new Runnable()
{
public void run()
{
createAndShowGUI();
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Delay the setVisible(false) with ~50 milliseconds.
Release Regression From : 1.4.2
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: 315884)
======================================================================
- duplicates
-
JDK-6483868 JDialog.setVisible(false) does not hide dialog.
- Closed
-
JDK-6377030 Frame.setVisible(false) does not always hide frame
- Closed
-
JDK-8173332 JDialog.setVisible(false) not honoured in some cases in a loop
- Closed
- relates to
-
JDK-4977351 Iconifying and restoring the frame on consecutive calls does not work on Solaris
- Closed
-
JDK-6267149 PIT: Frames are not iconifying on XToolkit
- Closed