Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import java.applet.Applet;
  2. import java.awt.*;
  3. /**
  4. *
  5. * @author Jamison Allen
  6. */
  7. public class Stars extends Applet {
  8.  
  9.  
  10. public void init() {
  11. resize (1680,1050);
  12. }
  13.  
  14. public void paint(Graphics g) {
  15.  
  16.  
  17.  
  18. g. setColor(Color.white);
  19. g. fillRect(0,0,1680,1050);
  20. int star, x, y, c,w ,h;
  21. star = 1;
  22. g. setColor(Color.white);
  23. while (star <= 1000){
  24. x = (int)(Math.random()*1680 + 0);
  25. y = (int)(Math.random()*1050 + 0);
  26. c = (int)(Math.random()*4 + 1);
  27. w = (int) (Math.random()*50 + 1);
  28. h = (int) (Math.random()*70 + 1);
  29. if (c == 1)
  30. g.setColor(Color.red);
  31. else if (c == 2)
  32. g. setColor(Color.blue);
  33. else if (c == 3)
  34. g. setColor(Color.cyan);
  35. else if (c == 4)
  36. g. setColor(Color.magenta);
  37.  
  38.  
  39.  
  40. g. drawRect(x,y,h,w);
  41. star += 1;
  42.  
  43. }
  44. }
  45.  
  46.  
  47. }
  48. Got it, thanks!It works!Thank you!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement