View difference between Paste ID: FJH30ba7 and 3HcfBJPp
SHOW: | | - or go back to the newest paste.
1-
private final static int pocetPoli = 10;
1+
private final static int pocetPoli = 10;
2
3
4
 private void naMalujCtverce(int pocetCtvercu) {
5
        int rozmer = getStrana() / pocetCtvercu;
6
7
        Graphics grafika = this.getGraphics();
8
9
        for (int i = 0; i <= rozmer * pocetCtvercu; i += rozmer) {
10
            for (int j = 0; j <= rozmer * pocetCtvercu; j += rozmer) {
11
12
                grafika.setColor(getBarva());
13
                grafika.fillRect(i, j, rozmer, rozmer);
14
                
15
                try {
16
                    Thread.sleep(100);
17
                } catch (InterruptedException ex) {
18
                    Thread.currentThread().interrupt();
19
                }
20
            }
21
22
        }
23
24
    }
25
26
    private int getStrana() {
27
        return Math.min(this.getWidth(), this.getHeight());
28
    }
29
30
    private Color getBarva() {
31
        Random rand = new Random();
32
33
        float r = rand.nextFloat();
34
        float g = rand.nextFloat();
35
        float b = rand.nextFloat();
36
37
        return new Color(r, g, b);
38
    }
39
40
    @Override
41
    public void paint(Graphics g) {
42
        super.paint(g); //To change body of generated methods, choose Tools | Templates.
43
        naMalujCtverce(pocetPoli);
44
    }