ColoredCircles -...

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

View Full Document Right Arrow Icon
//******************************************************************** // ColoredCircles.java Author: Lewis and Loftus // // Solution to Programming Project 3.22 //******************************************************************** / import javax.swing.JApplet; import java.awt.*; i public class ColoredCircles extends JApplet { private final int NUM_CIRCLES = 100; private final int MIN_DIAMETER = 5; private final int MAX_DIAMETER = 30; private final int MAX_COLORVALUE = 256; private final int MAX_X = 370; private final int MAX_Y = 170; //----------------------------------------------------------------- // Paints several circles of random color, diameter, and location.
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) { int x, y, diameter, red, green, blue; setBackground (Color.black); for (int count=1; count <= NUM_CIRCLES; count++) { x = (int) (Math.random() * MAX_X); y = (int) (Math.random() * MAX_Y); red = (int) (Math.random() * MAX_COLORVALUE); green = (int) (Math.random() * MAX_COLORVALUE); blue = (int) (Math.random() * MAX_COLORVALUE); page.setColor (new Color(red, green, blue)); diameter = (int) (Math.random() * MAX_DIAMETER) + MIN_DIAMETER; page.drawOval (x, y, diameter, diameter); } } }...
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