Repaint Error when trying to scroll in Browser? PLEASE HELP

I'm getting a repainting error ( the applet messes up and can't refresh the controls) when I try to scroll down in the IE 5.5 browser to view the rest of my applet. I noticed while scrolling, the applet does not seem to be repainting the controls properly in the exact spot as if the applet is moving faster then the scrollbars. I have no idea on what could be causing this problem. If anyone could help, I would greatly appreciate it.

System Configuration:

Using the java Plug-in 1.3

IE 5.5

on a Windows box using IIS 5.0 / Windows 2000

Applet is straight forward, has a couple buttons, adds buttons to a JPanel and then adds the JPanel to the ContentPane. And the .html applet size is 700 pixels in height to test the scrolling of the applet, but the applet in general is only 400 pixels in height.

thanks,

Peter Landis

[893 byte] By [ntwebdeveloper] at [2007-9-26 1:31:44]
# 1

Here's the code:

import java.awt.*;

import javax.swing.*;

public class TestRepaint extends JApplet

{

public void init()

{

Container contentPane = getContentPane();

JPanel panel = new JPanel();

panel.setBackground(Color.lightGray);

controls(panel);

// Grid

contentPane.add(panel);

}

public void controls(JPanel p)

{

JLabel imagelabel = new JLabel();

JLabel imagelabel2 = new JLabel();

// Create some labels

JLabel label_1 = new JLabel("TEST 1");

JLabel label_2 = new JLabel("TEST 2");

JLabel label_3 = new JLabel("TEST 3");

JLabel label_4 = new JLabel("TEST 4");

JLabel label_5 = new JLabel("TEST 5");

JLabel label_6 = new JLabel("TEST 6");

JLabel label_7 = new JLabel("TEST 7");

setLabelControl(label_1);

setLabelControl(label_2);

setLabelControl(label_3);

setLabelControl(label_4);

setLabelControl(label_5);

setLabelControl(label_6);

setLabelControl(label_7);

// Buttons

JButton b1 = new JButton("Button 1");

JButton b2 = new JButton("Button 2");

JButton b3 = new JButton("Button 3");

JButton b4 = new JButton("Button 4");

JButton b5 = new JButton("Button 5");

JButton b6 = new JButton("Button 6");

JButton b7 = new JButton("Button 7");

setButtonControl(b1);

setButtonControl(b2);

setButtonControl(b3);

setButtonControl(b4);

setButtonControl(b5);

setButtonControl(b6);

setButtonControl(b7);

// Layout

GridBagLayout gridbag = new GridBagLayout();

GridBagConstraints c = new GridBagConstraints();

p.setLayout(gridbag);

c.anchor = GridBagConstraints.WEST;

c.fill = GridBagConstraints.BOTH;

c.weightx = 1.0;

//////////////////////////////////////////////

c.gridwidth = 1;

// Note Inset is (Top, Left, Bottom, Right);

c.insets = new Insets(0,5,20,0);

p.add(label_3,c);

c.insets = new Insets(0,5,20,1);

p.add(b3,c);

c.insets = new Insets(0,5,20,0);

p.add(label_4,c);

c.gridwidth = GridBagConstraints.REMAINDER;

c.insets = new Insets(0,5,20,1);

p.add(b4,c);

/////////////////////////////////////////////

c.gridwidth = 1;

c.insets = new Insets(0,5,20,0);

p.add(label_5,c);

c.insets = new Insets(0,5,20,1);

p.add(b5,c);

c.insets = new Insets(0,5,20,0);

p.add(label_6,c);

c.gridwidth = GridBagConstraints.REMAINDER;

c.insets = new Insets(0,5,20,1);

p.add(b6,c);

}

public void setButtonControl(JButton button)

{

button.setBackground(Color.white);

}

void setLabelControl(JLabel l)

{

l.setFont(new Font("Helvetica", Font.BOLD, 14) );

l.setForeground(Color.black);

}

}

||||||||||||||||||||| HTML CODE |||||||||||||||||||

<title>Test</title>

<hr>

<!--"CONVERTED_APPLET"-->

<!-- CONVERTER VERSION 1.3 -->

<SCRIPT LANGUAGE="JavaScript"><!--

var _info = navigator.userAgent; var _ns = false;

var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);

//--></SCRIPT>

<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--

var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0)));

//--></SCRIPT></COMMENT>

<SCRIPT LANGUAGE="JavaScript"><!--

if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 425 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>');

else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "TestRepaint.class" WIDTH = 500 HEIGHT = 425 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>');

//--></SCRIPT>

<APPLET CODE = "TestRepaint.class" WIDTH = 500 HEIGHT = 425></XMP>

<PARAM NAME = CODE VALUE = "TestRepaint.class" >

<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">

<PARAM NAME="scriptable" VALUE="false">

</APPLET>

</NOEMBED></EMBED></OBJECT>

<!--

<APPLET CODE = "TestRepaint.class" WIDTH = 500 HEIGHT = 425>

</APPLET>

-->

<!--"END_CONVERTED_APPLET"-->

<hr>

ntwebdeveloper at 2007-6-29 1:31:45 > top of Java-index,Archived Forums,Swing...
# 2

Here's the problem. This error seems to be a problem when you are running the JSDK 1.3.0 or any plug-in such as the Java Plug-in 1.3.01. These releases currently have a problem with a repaint bug. If you upgrade the SDK to 1.3.1 or even the plug-in and run the applet, the repainting of the applet when you try scrolling is fixed. This must be a bug in the JDK 1.3.0 that have not yet been reported.

ntwebdeveloper at 2007-6-29 1:31:45 > top of Java-index,Archived Forums,Swing...