JDK-4458337 : Merlin: repaints do not work by using javaw on WinNT if double buffering is disa
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2001-05-14
  • Updated: 2002-08-20
  • Resolved: 2002-08-20
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
ingrid.yao@Eng 2001-05-14

This problem only happens on Win2000 machine, not on WinNT machine and
it only happens when you use javaw not java. If you enable double-buffering,
everything works fine.


J2SE Version (please include all output from java -version flag):

java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b62)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b62, mixed mode)

Does this problem occur on J2SE 1.3?  Yes / No (pick one)
no


Operating System Configuration Information (be specific):
Windows 2000 SP1;
Other platforms untested

Hardware Configuration Information (be specific):
PIII-800, 256 MB, Nvidia Geforce


Bug Description:

Timed repaints (probably all programmatically invoked repaints) do not work
in JDK 1.4 Merlin Swing if double buffering is disabled. If double-buffering
is disabled and repaint() is called repaints are executed only if events are
generated (for example the mouse is moved over the window).

This causes caret blinking in CodeGuide (our Java IDE) to cease working in
Merlin right now.


Test Program
=============

/**
 * This test program displays a frame which contains a solid rectangle whose
 * color alternates from black to white and back every 200ms.
 *
 * Works as advertized on JDK 1.3
 *
 * Only alternates from black to white if events are generated (i.e. the mouse
 * is moved across the window) on Merlin (b60).
 */

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class TimerTest
{
	/**
	 * This method is called after start up.
	 */
	public static void main(String[] args)
	{
		// Create application frame.
		JFrame frame = new JFrame();
		 RepaintManager.currentManager(frame).setDoubleBufferingEnabled(false);
		frame.getContentPane().add(new TestComponent());
		frame.pack();
		frame.show();
	}
	
	private static class TestComponent extends JComponent
	{
		private boolean displayBlack;
		
		public TestComponent()
		{
			Timer t = new Timer
			(
				200,
				new ActionListener()
				{
					public void actionPerformed(ActionEvent e)
					{
						displayBlack = ! displayBlack;
						repaint(getBounds());
					}
				}
			);
			
			t.setRepeats(true);
			t.start();
			
			setPreferredSize(new Dimension(300,300));
		}
		
		public void paintComponent(Graphics g)
		{
			Color c;
			if (displayBlack)
				c = Color.black;
			else
				c = Color.white;
			g.setColor(c);
			Rectangle r = g.getClipBounds();
			g.fillRect(r.x,r.y,r.width,r.height);
		}
	}
}


Comments
EVALUATION That it only happens on one environment seems to imply there is an underlying problem in the awt or 2d, I'm reassigning to awt. scott.violet@eng 2001-05-14 Commit to fix in merlin (paint problem). eric.hawkes@eng 2001-05-14 Name: ssR10077 Date: 07/01/2002 I can repeatedly reproduce the problem on WinNT Intel 850 MHz, Matrox G250 with java and javaw on Hopper builds from 03 to b14 with -Dsun.java2d.noddraw=true. I was able to reproduce it once with javaw on b11 without -Dsun.java2d.noddraw=true. Bug is reproducible with even simplier testcase. The bug is more reliable reproducible when window is moved paritialy offscreen and returned back. Dmitri Trembovetski tdv@eng was able to reproduce the bug on Solaris. import java.awt.*; class FrameTest extends Frame { public void paint(Graphics g) { g = getGraphics(); Rectangle r = getBounds(); g.clearRect(r.x,r.y,r.width,r.height); g.dispose(); } public static void main( String[] args ) { new FrameTest().setVisible(true); } } As test is awt independent I'm reassigning bug to 2d. ====================================================================== I don't believe I saw the same problem on solaris. The original testcase shows the problem on Win2K with javaw only, works fine with java. I believe this is a dup of 4374079: Win32:Lightweight components do not immediately repaint in response to repaint() ###@###.### 2002-08-20
20-08-2002

WORK AROUND Call Toolkit.getDefaultToolkit().sync(); when done with rendering. ###@###.### 2002-08-20
20-08-2002