Java框架屏幕截图显示重新粉刷
我正在执行应用程序的jframe
的屏幕截图,但通常会出现绘图伪影,例如在左上角的框架中的图像(不是通常的位置),因为我相信它在重新粉刷过程中抓住它。
有什么办法吗?我尝试在A Repaver()
希望它能保持完成后添加1/2秒延迟,但没有起作用(尽管出现问题的频率较低)。我认为合适的框架重新粉刷上有多个控件。我还设置了一个标志,以防止随时间延迟进行程序化重新粉刷,但是问题仍然蔓延。
我正在为屏幕截图使用以下代码:
BufferedImage img = new BufferedImage(this.getWidth(),this.getHeight(),BufferedImage.TYPE_INT_RGB);
this.paint(img.getGraphics());
File outputfile = new File(saveImageName);
ImageIO.write(img, ext, outputfile);
I'm performing screen shots of my app's JFrame
, but often a drawing artefact shows up, such as an image in my frame in the upper-left corner (not where it normally is), because I believe it's catching it during a repaint.
Any way around this? I've tried adding a 1/2 second delay after a repaint()
hoping it would stay finished, but didn't work (though problems occurred less often). I've got multiple controls on the frame repainting as they see fit. I've also set a flag to prevent programmatic repainting with the time delay, but problems still creep in.
I'm using the following code for the screenshot:
BufferedImage img = new BufferedImage(this.getWidth(),this.getHeight(),BufferedImage.TYPE_INT_RGB);
this.paint(img.getGraphics());
File outputfile = new File(saveImageName);
ImageIO.write(img, ext, outputfile);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论