Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package com.Graphics;
  2. import javax.swing.*;
  3. import java.awt.*;
  4. import java.util.concurrent.TimeUnit;
  5.  
  6. public class Rect_Draw extends JComponent {
  7. public void paintComponent(Graphics g){
  8. Graphics2D g2 = (Graphics2D) g;
  9. Rectangle box = new Rectangle(-50, 300, 50, 15);
  10. Rectangle clear = new Rectangle(0, 0, 2000, 2000);
  11. for (int i=0;i<=50;i++) {
  12.  
  13. g2.setColor(Color.RED);
  14. g2.fill(box);
  15. g2.draw(box);
  16.  
  17. box.translate(0, 15);
  18. g2.setColor(Color.ORANGE);
  19. g2.fill(box);
  20. g2.draw(box);
  21.  
  22. box.translate(0, 15);
  23. g2.setColor(Color.YELLOW);
  24. g2.fill(box);
  25. g2.draw(box);
  26.  
  27. box.translate(0, 15);
  28. g2.setColor(Color.GREEN);
  29. g2.fill(box);
  30. g2.draw(box);
  31.  
  32. box.translate(0, 15);
  33. g2.setColor(Color.BLUE);
  34. g2.fill(box);
  35. g2.draw(box);
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement