开发者

Infinite loop while displaying SVG, found problem, can't solve

I have a strange problem. Can somebody tell me why does my void "paint" go into an infinite loop. I checked and it only goes infinite when there is this.setURI(fi.toURL().toString()) surrounded wi开发者_高级运维th try/catch. When i start the program it prints svinja all the time until i close it (that's my test for infinite loop); I'm a beginner and would like the simplest solution. [: Thanks in advance.

p.s. I have all the necessary libraries so that's not a problem.

public class SVG_class extends JSVGCanvas {

    @Override
    public void paint(Graphics g) {

        System.out.println("svinja");

        super.paint(g);

        File fi = new File("C:\\Users\\Gigabyte\\Desktop\\SVG\\map1.svg");

        try {
            this.setURI(fi.toURL().toString());
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}


most likely the this.setURI results in paint being called. Which makes since since it would need to repaint after loading a new model. the solution would be take the setURI call out of paint. It doesn't belong there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜