显示SVG时无限循环,发现问题,无法解决
我有一个奇怪的问题。有人能告诉我为什么我的虚空“绘画”会进入无限循环吗?我检查了一下,只有当 this.setURI(fi.toURL().toString())
被 try
/catch
包围时,它才会变得无限。当我启动程序时,它一直打印 svinja
直到我关闭它(这是我对无限循环的测试);我是初学者,想要最简单的解决方案。 [: 提前致谢。
ps 我有所有必要的库,所以这不是问题。
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();
}
}
}
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 with 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();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最有可能的是
this.setURI
导致paint
被调用。这是因为加载新模型后需要重新绘制。解决方案是将setURI
调用从paint
中取出。它不属于那里。most likely the
this.setURI
results inpaint
being called. Which makes since since it would need to repaint after loading a new model. the solution would be take thesetURI
call out ofpaint
. It doesn't belong there.