laman

Rabu, 21 Desember 2011

thread

public class Kotak extends JPanel {

    private static GeneralPath gp;
    int jum = 1;

    // draw general paths
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Random random = new Random();
        Graphics2D g2d = (Graphics2D) g;


        g2d.translate(200, 200);

        if (jum == 18) {
            jum = 0;
        }

        for (int count = 1; count <= jum; count++) {
            g2d.rotate(Math.PI / 3.0);

            g2d.setColor(new Color(random.nextInt(256),
                    random.nextInt(256), random.nextInt(256)));
            g2d.fillRect(0, 0, 100, 100);
//         g2d.fill( starImage() );
        }
        jum++;
    }
    //bisa pake ini juga
//   public GeneralPath starImage()
//    {
//
//      int xPoints[] = { 0, 80,80, 0 };
//      int yPoints[] = { 0, 0,80, 80};
//
//      GeneralPath Kotak = new GeneralPath();
//
//
//      Kotak.moveTo( xPoints[ 0 ], yPoints[ 0 ] );
//
//
//      for ( int count = 1; count < xPoints.length; count++ )
//         Kotak.lineTo( xPoints[ count ], yPoints[ count ] );
//
//      Kotak.closePath(); // close the shape
//      return Kotak;
//    }
}

Tidak ada komentar:

Posting Komentar