Name: gm110360 Date: 09/14/2004
FULL PRODUCT VERSION :
JRE 1.4.2_05
JRE 1.5.0-rc
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000
5.00.2195
Service Pack 4
&
Windows XP SP2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Internet Explorer 6.0.2800.1106
A DESCRIPTION OF THE PROBLEM :
When scrolling in a browser containing large applets, excessive flashing occurs. This is not a limit of the environment, because the test applet draws the same JPanel in a JFrame, and when you scroll in the JFrame, there is no flashing. The problem doesn't seem to be with repaint itself, because moving other windows across the applet (or other actions that should force a repaint) do not cause the same flashing. It seems to be related specifically to the browser hooks that call repaint on the applet in response to browser scrolling. This behavior has been observed in both Internet Explorer and Firefox with both 1.4.2_05 and JRE 1.5.0-rc versions of the Java Plug-in.
The test code creates two instances of a JPanel that draws a simple image. One instance of the JPanel is displayed in the browser and one is displayed in a pop-up JFrame. By scrolling up and down in each, you can see a dramatic difference between the two. The instance in the JFrame stays solid with minimal or no flashing while the instance in the browser exhibits extreme flashing.
Note: This is not related to double-buffering, because the test applet does double buffer - it simply does a drawImage() of the cached image. This is also not related to not overriding update(), because the test applet is using Swing components where the update calls paint() without clearing the area.
This is very evident using IE as opposed to Mozilla/Firefox.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run applet. In Pop-up JFrame, scroll up and down - notice minimal or no flashing. In browser, scroll up and down - notice excessive flashing.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Minimal flashing of applet in browser (or at least on par with scrolling in JFrame).
ACTUAL -
Excessive flashing of applet in browser.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
// TestApplet.java
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
public class TestApplet extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(new TestPanel(), BorderLayout.CENTER);
new TestFrame();
}
}
class TestFrame extends JFrame
{
TestFrame()
{
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(new JScrollPane(new TestPanel()), BorderLayout.CENTER);
setSize(Toolkit.getDefaultToolkit().getScreenSize());
show();
}
}
class TestPanel extends JPanel
{
BufferedImage bufferedImage;
TestPanel()
{
initImage();
setPreferredSize(new Dimension(1700, 1700));
}
// Creates buffered image (a simple red square on a black background).
// Only done once.
private void initImage()
{
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
bufferedImage = gc.createCompatibleImage(1700, 1700);
Graphics2D g2D = bufferedImage.createGraphics();
g2D.setColor(Color.red);
g2D.fillRect(400, 400, 200, 200);
}
// Simply draw the cached image.
public void paintComponent(Graphics g)
{
g.drawImage(bufferedImage, 0, 0, null);
}
}
// --------------------------------------------------------------------------------
// test.jar simply contains the three class files generated from the
// above java source
// test.html
<html>
<head>
<title>Test</title>
</head>
<body>
<applet code="TestApplet" archive="test.jar" width="1700" height="1700">
</body>
</html>
---------- END SOURCE ----------
(Incident Review ID: 305541)
======================================================================
###@###.### 2004-09-28
FULL PRODUCT VERSION :
JRE 1.4.2_05
JRE 1.5.0-rc
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000
5.00.2195
Service Pack 4
&
Windows XP SP2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Internet Explorer 6.0.2800.1106
A DESCRIPTION OF THE PROBLEM :
When scrolling in a browser containing large applets, excessive flashing occurs. This is not a limit of the environment, because the test applet draws the same JPanel in a JFrame, and when you scroll in the JFrame, there is no flashing. The problem doesn't seem to be with repaint itself, because moving other windows across the applet (or other actions that should force a repaint) do not cause the same flashing. It seems to be related specifically to the browser hooks that call repaint on the applet in response to browser scrolling. This behavior has been observed in both Internet Explorer and Firefox with both 1.4.2_05 and JRE 1.5.0-rc versions of the Java Plug-in.
The test code creates two instances of a JPanel that draws a simple image. One instance of the JPanel is displayed in the browser and one is displayed in a pop-up JFrame. By scrolling up and down in each, you can see a dramatic difference between the two. The instance in the JFrame stays solid with minimal or no flashing while the instance in the browser exhibits extreme flashing.
Note: This is not related to double-buffering, because the test applet does double buffer - it simply does a drawImage() of the cached image. This is also not related to not overriding update(), because the test applet is using Swing components where the update calls paint() without clearing the area.
This is very evident using IE as opposed to Mozilla/Firefox.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run applet. In Pop-up JFrame, scroll up and down - notice minimal or no flashing. In browser, scroll up and down - notice excessive flashing.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Minimal flashing of applet in browser (or at least on par with scrolling in JFrame).
ACTUAL -
Excessive flashing of applet in browser.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
// TestApplet.java
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
public class TestApplet extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(new TestPanel(), BorderLayout.CENTER);
new TestFrame();
}
}
class TestFrame extends JFrame
{
TestFrame()
{
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(new JScrollPane(new TestPanel()), BorderLayout.CENTER);
setSize(Toolkit.getDefaultToolkit().getScreenSize());
show();
}
}
class TestPanel extends JPanel
{
BufferedImage bufferedImage;
TestPanel()
{
initImage();
setPreferredSize(new Dimension(1700, 1700));
}
// Creates buffered image (a simple red square on a black background).
// Only done once.
private void initImage()
{
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
bufferedImage = gc.createCompatibleImage(1700, 1700);
Graphics2D g2D = bufferedImage.createGraphics();
g2D.setColor(Color.red);
g2D.fillRect(400, 400, 200, 200);
}
// Simply draw the cached image.
public void paintComponent(Graphics g)
{
g.drawImage(bufferedImage, 0, 0, null);
}
}
// --------------------------------------------------------------------------------
// test.jar simply contains the three class files generated from the
// above java source
// test.html
<html>
<head>
<title>Test</title>
</head>
<body>
<applet code="TestApplet" archive="test.jar" width="1700" height="1700">
</body>
</html>
---------- END SOURCE ----------
(Incident Review ID: 305541)
======================================================================
###@###.### 2004-09-28