Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Graphics;
- import javax.swing.*;
- import java.awt.*;
- import java.util.concurrent.TimeUnit;
- public class Rect_Draw extends JComponent {
- public void paintComponent(Graphics g){
- Graphics2D g2 = (Graphics2D) g;
- Rectangle box = new Rectangle(-50, 300, 50, 15);
- Rectangle clear = new Rectangle(0, 0, 2000, 2000);
- for (int i=0;i<=50;i++) {
- g2.setColor(Color.RED);
- g2.fill(box);
- g2.draw(box);
- box.translate(0, 15);
- g2.setColor(Color.ORANGE);
- g2.fill(box);
- g2.draw(box);
- box.translate(0, 15);
- g2.setColor(Color.YELLOW);
- g2.fill(box);
- g2.draw(box);
- box.translate(0, 15);
- g2.setColor(Color.GREEN);
- g2.fill(box);
- g2.draw(box);
- box.translate(0, 15);
- g2.setColor(Color.BLUE);
- g2.fill(box);
- g2.draw(box);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement