Problems with threads and graphs

56 views Asked by At

I am working on a project linked to Prim's algorithm. I want to make yellow some circles in a frame, after 2 seconds to show how the algorithm works. Actually, I have a problem with the code below because, after I compile, it waits 10 seconds (total time of waiting) with a blank frame. After the 10 seconds the frame shows me all resolved. Why did it worked like that and how can I make it work correctly?

        try {
            Thread.sleep(2000);
            g.setColor(Color.YELLOW);
            g.fillOval(x[v],y[v],30,30);
            g.setColor(Color.BLACK);
            g.drawString("The found edge is "+(u+1)+" ->"+(v+1)+" by price "+min, 320, b);
            b=b+20;
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
0

There are 0 answers