Make your own free website on Tripod.com

First Shapes

import java.awt.*;// import java.applet.Applet;// import java.awt.event.*;// import java.util.Random;// import java.awt.Font;// import java.awt.Color;// import java.awt.Image;// public class StarTest extends Applet implements ActionListener { private TextField numField; private int numStars=0; Random generator=new Random(); Font f=new Font("Dialog", Font.BOLD, 25); Image guitarImage; private void drawStars(Graphics g, int x, int y, int w, int l) { g.drawLine(x, y, x-w/2, y-l); g.drawLine(x-w/2, y-l, x-w, y); g.drawLine(x-w, y, x+w/10, y-l*2/3); g.drawLine(x+w/10, y-l*2/3, x-l-w/10, y-l*2/3); g.drawLine(x-l-w/10, y-l*2/3, x, y); } public void init() { Label fieldLabel; fieldLabel=new Label("How Many Stars?"); add(fieldLabel); numField=new TextField(4); add(numField); numField.addActionListener(this); } public void actionPerformed(ActionEvent event) { numStars=Integer.parseInt(numField.getText()); repaint(); } public void paint(Graphics g) { Color[] colorArray={Color.black, Color.blue, Color.cyan, Color.darkGray, Color.gray, Color.green, Color.lightGray, Color.magenta, Color.orange, Color.pink, Color.red, Color.yellow}; for(int i=0; i