Hi there
I am new, I hope I dont ask something you already had a dozen times.
I have just been working on some small experiments for Java 2D Games, using Polygons. Once do draw rectangular tiles with height, once to draw Hex fields.
I did one of these tests as Applet, the other as standalone Application with a Frame. And I took performance measures of my paint method with System.nanoTime().
Now the problem I found was, that the drawing in the Applet was extremely fast, while the drawing in the Frame was extremely slow. To verify this, i wrote a performance test. I createt a “load” class which just has 400 4-edged polygons. Then I had Java draw these 400 polys, once in a Frame and once in an Applet. The Applet did the paint method in like 1 ms, while the Frame took up to 400 ms.
I tried everything through. No backbuffer, BufferedImage as backbuffer, VolatileImage as backbuffer, or a BufferStrategy. I usually get a 400 ms performance. When I use a createCompatibleImage Method instead of new BufferedImage i manage to get around 200 ms. When I draw directly on the frame.getGraphics() I get around 100 ms, but it flickers.
In the end, I have 2 questions:
- Why is the Applet so much faster in doing the same? Can anyone verify this experience?
 - What can I do to improve my Performance?
 
My main PC is a 450 MHz CPU and not really that fast. But I have a Notebook with 2 GHz and I expect good results at least there.
Thanks
-JAW
The code of the load class
import java.awt.*;
import java.awt.geom.*;
import java.util.*;
public class Last
{
	Polygon[] polys;
	Color[] col;
	
	Last(int anzahl)
	{
		polys = new Polygon[anzahl];
		col = new Color[anzahl];
		Random rnd = new Random(12345678);
		for( int i = 0; i < anzahl; i++ )
		{
			Polygon p = new Polygon();
			p.addPoint(rnd.nextInt(800),rnd.nextInt(600));
			p.addPoint(rnd.nextInt(800),rnd.nextInt(600));
			p.addPoint(rnd.nextInt(800),rnd.nextInt(600));
			p.addPoint(rnd.nextInt(800),rnd.nextInt(600));
			polys[i] = p;
			col[i] = new Color(0,rnd.nextInt(200)+50,0);
		}
	}
	
	public void zeichne(Graphics2D g2d)
	{
		for( int i = 0; i < polys.length; i++ )
		{
			g2d.setColor(col[i]);
			g2d.fill(polys[i]);
		}
	}
}
        
      
    