- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 - 41
 - 42
 - 43
 - 44
 - 45
 - 46
 - 47
 - 48
 - 49
 - 50
 - 51
 - 52
 - 53
 - 54
 - 55
 - 56
 - 57
 - 58
 
                        import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ExperimentNew {
    int x = 10;
    int y = 10;
    public static void main(String[] args) {
        ExperimentNew experimentNew = new ExperimentNew();
        experimentNew.go();
    }
    public void go(){
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        MyDrawPanel panel = new MyDrawPanel();
        frame.getContentPane().add(panel);
        frame.setSize(500,500);
        frame.setVisible(true);
        for (int i = 0; i < 450; i++){
            if (i < 226) {
                x++;
                y++;
                panel.repaint();
                try {
                    Thread.sleep(50);
                } catch (Exception ignored) {
                }
            }else{
                x++;
                y--;
                panel.repaint();
                try{
                    Thread.sleep(50);
                }catch(Exception ignored){ }
            }
        }
    }
    class MyDrawPanel extends JPanel{
        public void paintComponent(Graphics g){
            g.setColor(Color.white);
            g.fillRect(0,0, this.getWidth(), this.getHeight());
            int one = (int) (Math.random() * 255);
            int two = (int) (Math.random() * 255);
            int three = (int) (Math.random() * 255);
            Color color = new Color(one, two, three);
            g.setColor(color);
            g.fillOval(x, y, 20, 20);
        }
    }
}
                                 
        
            Мигающая анимационная окружность! КАК СДЕЛАТЬ БОЛЕЕ КОМПАКТНО?
        
        
Комментарии (0) RSS
Добавить комментарий