JDK-4684354 : JFrame/JDialog on WIndows flickers severely when setEnabled()
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-05-13
  • Updated: 2002-07-22
  • Resolved: 2002-07-22
Related Reports
Duplicate :  
Description

Name: jk109818			Date: 05/13/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION : W2000 SP2


A DESCRIPTION OF THE PROBLEM :
Scenario: In a busy JFrame/JDialog (i.e. where it takes a
while to repaint) setEnabled(false) is called to prevent
user input - and later enabled again.

On Windows only (does not appear on Solaris and Linux) the
screen is erased with the default background (i.e. user
looks at empty window) - then the double buffer is filled
and then copied (i.e. the user sees the content again). The
user looks at the empty screen for up to 2 seconds on busy
screens.

The behavior is independent from the selected look & feel.

I assume that this is a Windows Native Library Timing
issue, as everything is nice and smooth on Solaris and
Linux.
The issue might might be related to the bug with review id
144485.

REGRESSION.  Last worked in version 1.3.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run the example
2. Press on the button.
3. You see a brief flicker on Windows as the exaple is a
very simple screen.
4. If you want to see it more dramatically, use a Look and
Feel using colored backgrounds or create a window with lots
of work for the repaint().
5. Using repaint() alone does not show the empty window
(i.e. works correctly).

EXPECTED VERSUS ACTUAL BEHAVIOR :
No flickering (as on Linux & Solaris and with Java 1.3.1)
at all.

The empty window should NOT be painted in the first place.


This bug can be reproduced always.

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

public class JavaBug2 extends JFrame
{
	private JPanel jPanel1 = new JPanel();
	private JLabel jLabel1 = new JLabel();
	private JTextField jTextField1 = new JTextField();
	private JLabel jLabel2 = new JLabel();
	private JTextField jTextField2 = new JTextField();
	private JButton jButton1 = new JButton();
	private JCheckBox jCheckBox1 = new JCheckBox();

	public JavaBug2()
	{
		try
		{
			jbInit();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}

		pack();
		setVisible(true);
	}
	public static void main(String[] args)
	{
		JavaBug2 javaBug2 = new JavaBug2();
	}
	private void jbInit() throws Exception
	{
		this.setDefaultCloseOperation(3);
		jLabel1.setText("jLabel1");
		jTextField1.setText("jTextField1");
		jLabel2.setText("jLabel2");
		jTextField2.setText("jTextField2");
		jButton1.setText("jButton1");
		jButton1.addActionListener(new java.awt.event.ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				jButton1_actionPerformed(e);
			}
		});
		jCheckBox1.setText("jCheckBox1");
		this.getContentPane().add(jPanel1, BorderLayout.CENTER);
		jPanel1.add(jLabel1, null);
		jPanel1.add(jTextField1, null);
		jPanel1.add(jLabel2, null);
		jPanel1.add(jTextField2, null);
		jPanel1.add(jCheckBox1, null);
		jPanel1.add(jButton1, null);
	}

	void jButton1_actionPerformed(ActionEvent e)
	{
		setEnabled(false);
		try
		{
			Thread.sleep(1000);
		}
		catch (Exception ee)
		{}
		setEnabled(true);
	}
}

---------- END SOURCE ----------
(Review ID: 144488) 
======================================================================

Comments
EVALUATION Name: ssR10077 Date: 07/22/2002 Duplicate of 4096745 ======================================================================
11-06-2004