Details
-
Bug
-
Resolution: Duplicate
-
P5
-
None
-
5.0
-
x86
-
linux
Description
FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux andromeda.basis.com 2.6.14-1.1644_FC4 #1 Sun Nov 27 03:25:11 EST 2005 i686 i686 i386 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Using KDE 3.4.2-0.fc4.1, X.org 6.8.2-37.FC4.49.2 on a 2.4 GHz machine with 1GB RAM.
A DESCRIPTION OF THE PROBLEM :
A quick succession of setVisible(true) and setVisible(false) on multiple Frame objects separated by calls to EventQueue.invokeLater() does not always cause all the Frames to become invisible. When this happens, the contents of the frame are invisible, but the frames themselves remain on the screen. THIS IS A TIMING ISSUE, so please don't discount if you don't see it immediately. In our application it's more prevalent than with this test.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the sample. Runnable1 creates a frame and sets it vislble. Runnable2 sets the frame invisible. The sample creates and runs 7 Runnable1's and 7 Runnable2's each in a different invokeLater(). To see the behavior, run the sample, and click the "Hello" button. It may be necessary to try it multiple times.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the frames to always become invisible.
ACTUAL -
Occasionally, one or more of the 7 frames will remain visible.
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;
import javax.swing.JButton;
import javax.swing.JFrame;
public class SetVisibleTest
{
private static Runnable[] m_defaultRunnables;
public static void main(String[] args)
{
m_defaultRunnables = new Runnable[14];
for (int i = 0; i < 7; ++i)
{
Runnable1 runnable1 = new Runnable1(i);
m_defaultRunnables[i] = runnable1;
m_defaultRunnables[i + 7] = new Runnable2(runnable1);
}
new Runnable1(999).run();
}
private static class Runner implements Runnable
{
private int m_sequence = 0;
private final Runnable[] m_runnables;
Runner(Runnable[] p_runnables)
{
m_runnables = p_runnables;
}
public void run()
{
if (m_sequence < m_runnables.length)
{
m_runnables[m_sequence++].run();
EventQueue.invokeLater(this);
}
}
}
private static class Runnable1 implements Runnable
{
private JFrame m_frame;
private final int m_count;
Runnable1(int p_count)
{
m_count = p_count;
}
public void run()
{
m_frame = new JFrame("Frame " + m_count);
m_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
m_frame.getContentPane().setLayout(new FlowLayout());
JButton button = new JButton("Hello");
ActionListener listener =
new ActionListener()
{
public void actionPerformed(ActionEvent p_ev)
{ EventQueue.invokeLater(new Runner(m_defaultRunnables)); }
};
button.addActionListener(listener);
m_frame.pack();
m_frame.setSize(500, 400);
m_frame.setVisible(true);
}
public JFrame getFrame()
{ return m_frame; }
}
private static class Runnable2 implements Runnable
{
private final Runnable1 m_runnable1;
Runnable2(Runnable1 p_runnable1)
{ m_runnable1 = p_runnable1; }
public void run()
{ m_runnable1.getFrame().setVisible(false); }
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None found
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux andromeda.basis.com 2.6.14-1.1644_FC4 #1 Sun Nov 27 03:25:11 EST 2005 i686 i686 i386 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Using KDE 3.4.2-0.fc4.1, X.org 6.8.2-37.FC4.49.2 on a 2.4 GHz machine with 1GB RAM.
A DESCRIPTION OF THE PROBLEM :
A quick succession of setVisible(true) and setVisible(false) on multiple Frame objects separated by calls to EventQueue.invokeLater() does not always cause all the Frames to become invisible. When this happens, the contents of the frame are invisible, but the frames themselves remain on the screen. THIS IS A TIMING ISSUE, so please don't discount if you don't see it immediately. In our application it's more prevalent than with this test.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the sample. Runnable1 creates a frame and sets it vislble. Runnable2 sets the frame invisible. The sample creates and runs 7 Runnable1's and 7 Runnable2's each in a different invokeLater(). To see the behavior, run the sample, and click the "Hello" button. It may be necessary to try it multiple times.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the frames to always become invisible.
ACTUAL -
Occasionally, one or more of the 7 frames will remain visible.
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;
import javax.swing.JButton;
import javax.swing.JFrame;
public class SetVisibleTest
{
private static Runnable[] m_defaultRunnables;
public static void main(String[] args)
{
m_defaultRunnables = new Runnable[14];
for (int i = 0; i < 7; ++i)
{
Runnable1 runnable1 = new Runnable1(i);
m_defaultRunnables[i] = runnable1;
m_defaultRunnables[i + 7] = new Runnable2(runnable1);
}
new Runnable1(999).run();
}
private static class Runner implements Runnable
{
private int m_sequence = 0;
private final Runnable[] m_runnables;
Runner(Runnable[] p_runnables)
{
m_runnables = p_runnables;
}
public void run()
{
if (m_sequence < m_runnables.length)
{
m_runnables[m_sequence++].run();
EventQueue.invokeLater(this);
}
}
}
private static class Runnable1 implements Runnable
{
private JFrame m_frame;
private final int m_count;
Runnable1(int p_count)
{
m_count = p_count;
}
public void run()
{
m_frame = new JFrame("Frame " + m_count);
m_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
m_frame.getContentPane().setLayout(new FlowLayout());
JButton button = new JButton("Hello");
ActionListener listener =
new ActionListener()
{
public void actionPerformed(ActionEvent p_ev)
{ EventQueue.invokeLater(new Runner(m_defaultRunnables)); }
};
button.addActionListener(listener);
m_frame.pack();
m_frame.setSize(500, 400);
m_frame.setVisible(true);
}
public JFrame getFrame()
{ return m_frame; }
}
private static class Runnable2 implements Runnable
{
private final Runnable1 m_runnable1;
Runnable2(Runnable1 p_runnable1)
{ m_runnable1 = p_runnable1; }
public void run()
{ m_runnable1.getFrame().setVisible(false); }
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None found
Attachments
Issue Links
- duplicates
-
JDK-5109571 REGRESSION: JDialog.setVisible(false) not honoured
- Closed