JDK-6267126 : Flickering when a new JFrame is launched
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-05-09
  • Updated: 2010-04-02
  • Resolved: 2005-07-12
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :


ADDITIONAL OS VERSION INFORMATION :
Windows XP

A DESCRIPTION OF THE PROBLEM :
When a JDialog is created and set to visible there is a flicker. First JDialog background paints. Then contents paint. For example:

newDialog = new JDialog();
newDialog.setModal(true);
newDialog.setSize(new Dimension(600,400));
newDialog.setBackground(Color.red);
JPanel greenPanel = new JPanel();
greenPanel.setBackground(Color.green);
newDialog.getContentPane().add(greenPanel);

After you set the newDialog to visible you see the red first, then green. I would expect that the entire dialog would be painted and then final result is displayed. Instead we see the empty frame first. Thus resulting in a flicker.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
When a JDialog is created and set to visible there is a flicker. First JDialog background paints. Then contents paint. For example:

newDialog = new JDialog();
newDialog.setModal(true);
newDialog.setSize(new Dimension(600,400));
newDialog.setBackground(Color.red);
JPanel greenPanel = new JPanel();
greenPanel.setBackground(Color.green);
newDialog.getContentPane().add(greenPanel);

After you set the newDialog to visible you see the red first, then green. I would expect that the entire dialog would be painted and then final result is displayed. Instead we see the empty frame first. Thus resulting in a flicker.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect that the entire dialog would be painted and then final result is displayed. 

ACTUAL -
After you set the newDialog to visible you see the red first, then green. I would expect that the entire dialog would be painted and then final result is displayed. Instead we see the empty frame first. Thus resulting in a flicker.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;

public class Test
{
	public static void main(String[] args) 
	{
		JDialog newDialog = new JDialog();
		newDialog.setModal(true);
		newDialog.setSize(new Dimension(600,400));
		newDialog.setBackground(Color.red);
		JPanel greenPanel = new JPanel();
		greenPanel.setBackground(Color.green);
		newDialog.getContentPane().add(greenPanel);
		newDialog.setVisible(true);
	}
}

---------- END SOURCE ----------
###@###.### 2005-05-09 08:24:07 GMT

Comments
EVALUATION The gray rect fix, 4967886, has fixed this! ###@###.### 2005-07-12 20:59:38 GMT
12-07-2005