Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.applet.Applet;
- import java.awt.*;
- /**
- *
- * @author Jamison Allen
- */
- public class Stars extends Applet {
- public void init() {
- resize (1680,1050);
- }
- public void paint(Graphics g) {
- g. setColor(Color.white);
- g. fillRect(0,0,1680,1050);
- int star, x, y, c,w ,h;
- star = 1;
- g. setColor(Color.white);
- while (star <= 1000){
- x = (int)(Math.random()*1680 + 0);
- y = (int)(Math.random()*1050 + 0);
- c = (int)(Math.random()*4 + 1);
- w = (int) (Math.random()*50 + 1);
- h = (int) (Math.random()*70 + 1);
- if (c == 1)
- g.setColor(Color.red);
- else if (c == 2)
- g. setColor(Color.blue);
- else if (c == 3)
- g. setColor(Color.cyan);
- else if (c == 4)
- g. setColor(Color.magenta);
- g. drawRect(x,y,h,w);
- star += 1;
- }
- }
- }
- Got it, thanks!It works!Thank you!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement