DrawStars -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // DrawStars.java Author: Lewis and Loftus // // Solution to Programming Project 6.16 //******************************************************************** import javax.swing.JApplet; import java.awt.Color; import java.awt.Point; import java.awt.Graphics; import java.util.Random; public class DrawStars extends JApplet { private final int APPLET_WIDTH = 200; private final int APPLET_HEIGHT = 200; private Random gen = new Random (); //----------------------------------------------------------------- // Draws several stars of random size and color in random // locations.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //-----------------------------------------------------------------public void paint (Graphics page) { setBackground (Color.black); Star star; int radius, red, green, blue, xCenter, yCenter; Color color; Point center; for (int count = 1; count <= 10; count++) { radius = gen.nextInt(10) + 10; red = gen.nextInt (156) + 100; green = gen.nextInt (156) + 100; blue = gen.nextInt (156) + 100; color = new Color (red, green, blue); xCenter = gen.nextInt (180) + 10; yCenter = gen.nextInt (180) + 10; center = new Point (xCenter, yCenter); star = new Star (radius, color); star.draw (center, page); } } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online