How can I repeat a Java Swing function?

0

Good I want to repeat my function that generates a random position in the frame and moves me a place label. But I execute function 1 only once. Does anyone have a solution? I leave the code, my idea is that when you press a -button, the function will be performed. It will be repeated 100 times the generate function.

public void generar(){
            int x=(int)(Math.random()*300);
            int y=(int)(Math.random()*300);
            lbl1.setLocation(x, y);
    }

    public void traer(){


        for(int i=0; i<100;i++){
            generar();

        }


    }
    
asked by F F 28.10.2018 в 23:34
source

0 answers