开发者

Temporarily disable double buffering in Java graphics applet

开发者 https://www.devze.com 2023-01-23 23:56 出处:网络
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 pur

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.


You could try by doing something like

yourComponent.setDoubleBuffered(false);
// your print code
yourComponent.setDoubleBuffered(true);

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..


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.

0

精彩评论

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