That is seriously broken HTML. Once you fix the Java applet
problem (or sooner), I strongly recommend validating it.
Your code has deprecated methods that are easily replaced,
look into the -Xlint compilation option.
You might have to let it sit for 10 minutes ..
...and it works a lot quicker if you make it 200x150,
rather than 800x600.
...or more until it stops updating.
I tried the run using MSVM for about 10 minutes before I
gave up on it.
It is interesting to note, however, that it runs *much* more
slowly than in Sun's 1.5.0 beta VM.
..The update routine is still getting called, though, as you
can check by viewing the console. I compiled it on linux java 1.4.2
with -target 1.1.
Thanks for taking the effort, but I am not prepared to point
the MSVM at any class file on the internet. The MSVM is still
insecure, and could open up a PC to the Trojan Byte Verifier
virus, amongst other things.
The *only* classes I am prepared to load in the MSVM are ones
that I have compiled myself, from source I have examined.
I will keep trying the local code, to see if it falls over
(it might be a memory leak that is ameliorated by the
ridiculously small canvss size I set..) It might be an idea
to use this source yourself and see if the problem is still
evident.
Here is the slight variant of your code that I am using.
<sscce>
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
class BrokenCanvas extends Canvas {
public static final long serialVersionUID = 1;
BrokenFrame pg;
BrokenCanvas(BrokenFrame p) { pg = p; }
public void update(Graphics g) { pg.updateBroken(g); }
public void paint(Graphics g) { pg.updateBroken(g); }
};
public class Broken extends Applet {
public static final long serialVersionUID = 1;
BrokenFrame ogf;
public void init() {
ogf = new BrokenFrame(this);
ogf.init();
}
};
class BrokenFrame extends Frame {
public static final long serialVersionUID = 1;
Dimension size = new Dimension(100, 75);
Image dbimage;
int pause = 10;
BrokenCanvas cv;
Broken applet;
BrokenFrame(Broken a) {
super("Broken Applet");
applet = a;
}
public void init() {
cv = new BrokenCanvas(this);
add(cv);
pack();
setSize( size );
handleResize();
setVisible(true);
cv.repaint();
}
void handleResize() {
dbimage = createImage(size.width, size.height);
System.out.println(dbimage);
}
public void paint(Graphics g) {
cv.repaint();
}
int x = 0;
public void updateBroken(Graphics realg) {
if (dbimage == null)
handleResize();
Graphics g = dbimage.getGraphics();
g.setColor(Color.black);
g.fillRect(0, 0, size.width, size.height);
g.setColor(Color.white);
g.drawLine(x, 0, 0, x);
x = (x+1) & 255;
if (!realg.drawImage(dbimage, 0, 0, this))
System.out.println("Drawimage returned false");
cv.repaint(pause);
if (x == 0)
System.out.println("updateBroken");
}
}
</sscce>