This code takes about 8 seconds (Java 1.4):
canvas = new Canvas();
canvas.setBackground(new Color(0, 0, 0));
canvas.setBounds(0, 0, 640, 480);
applet.add("Center", canvas); // <- BIG STALL HERE
This code takes <1 sec:
canvas = new Canvas();
applet.add("Center", canvas); // <- No stall here
canvas.setBackground(new Color(0, 0, 0));
canvas.setBounds(0, 0, 640, 480);
Bizarre…
Moral of the story: Add the canvas straight after you build it.
- Dom
modified - I forgot to change the 2nd code snippet - Oops! :-[