暂时禁用 Java 图形小程序中的双缓冲
如果需要的话,有没有一种简单的方法可以在java小程序中禁用双缓冲? 我有一个 Java 小程序,可以显示乐谱并为其设置动画,因此我需要它双缓冲。但是出于教学目的,我需要打印这个小程序。问题是,在我添加缓冲之前,打印机的输出是基于矢量的,因此我可以将其设为我想要的大小,并且看起来很平滑(并且还使用更便宜的黑色墨水类型!),但是使用双缓冲输出当然是一张图像,而且是分辨率相当低的图像!
基本上,我需要相同的小程序来在使用“display_tune”参数调用时使用双缓冲,但在使用“view_tune”参数调用时使用矢量输出直接绘制图形。< /strong>
非常感谢任何帮助。
is there an easy way to disable double buffering in a java applet if necessary?
I have a java applet that displays and animates a musical score so I needed it double buffered. However for teaching purposes I need to print this applet. The problem is that before I added buffering the output to the printer was vector based so I could make it as big as I wanted and it would look smooth (and also use the cheaper type of black ink!) but with the double buffering the output is of course an image, and a fairly low res one at that!
Basically I need the same applet to use double buffering when it is called with the "display_tune" parameter but to draw straight to graphics with vector output when it's called with the "view_tune" parameter.
Any help much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试执行类似于
JComponent 中声明的方法之类的操作。我使用这个解决方案从 Jung 图中导出 PNG,它起作用了。我不确定 Jung 是否将其组件内的方法重写为不同的东西,但尝试并没有什么坏处。
You could try by doing something like
the method is declared in
JComponent
. I used this solution to export a PNG from a Jung graph and it worked. I'm not sure if Jung overrides that method inside their components to a different thing but there's not hurt in trying..您应该全局禁用双缓冲,而不仅仅是一个组件。 Swing 有一个名为 RepaintManager 的东西。它允许您启用和禁用双缓冲。
You should globally disable double buffering, not just for one component. Swing has something called a RepaintManager. It allows you to enable and disable double buffering.