Interesting performance tip...

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! :-[

[quote]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();  // <- No stall here
  canvas.setBackground(new Color(0, 0, 0));
  canvas.setBounds(0, 0, 640, 480);
  applet.add("Center", canvas);
  

Bizarre…
[/quote]
Yeah; what’s the difference, exactly?

Anyway, I have an outstanding bug on loading and starting of applets in 1.4.x where sometimes applets can crash on startup - and never get to display anything - under linux. I narrowed it down to a race condition somewhere in Sun’s code. It’s been accepted but not yet fixed. Who knows how much more screwed code there is in applet startup ? :slight_smile:

Hmm I dunno but you AIR take your life into your hands modifying live AWt components as it is not thread-safe…