Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- public class Panel extends JPanel {
- private int value = 0;
- public Panel() {
- setLayout(null);
- Timer timer = new Timer(200, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- value++;
- if (value == 256)
- value = 0;
- repaint();
- }
- });
- timer.start();
- }
- public void paintComponent(Graphics graphics) {
- super.paintComponent(graphics);
- for (int i = 0; i <= 255; i++) {
- graphics.setColor(new Color(0, (i * value) % 255, 0));
- graphics.drawRect(250 - i / 2, 220 - i / 2, i, i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement