Ciao a tutti, mi affido a voi per risolvere un problema che non rieco a risolvere... praticamente devo disegnare dei triangoli a random che vengono visualizzati su una finestra utilizzando GeneralPath... ma quando avvio il programma, la finestra va in tilt e non mi fa visualizzare nulla. Qualcuno così gentile saprebbe individuare cos'è che è sbagliato?

codice:
import java.awt.*;
import java.awt.geom.*;
import java.util.*;
import javax.swing.*;
public class Triangles extends JPanel
{
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		Graphics2D gg = (Graphics2D) g;
		
		Random random = new Random();
		
		GeneralPath[] triangle = new GeneralPath[10];
		
		int numberOf = random.nextInt(10);
		
		for (int i=0;i<numberOf;i++)
		{
			triangle[i].moveTo(random.nextInt(400),random.nextInt(150));
			triangle[i].lineTo(random.nextInt(400),random.nextInt(150));
			triangle[i].lineTo(random.nextInt(400),random.nextInt(150));
			triangle[i].closePath();
			gg.fill(triangle[i]);
		}
	}
	public static void main(String[] args)
	{
		Triangles panel = new Triangles();
		JFrame frame = new JFrame("Triangles");
		frame.setSize(400,150);
		frame.setLocationRelativeTo(null);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		frame.add(panel);
		
		frame.setVisible(true);
	}
}