Skip to main content

Swing's BufferStrategy not overt..

4 replies [Last post]
stolsvik
Offline
Joined: 2006-09-17
Points: 0

Swing's BufferStrategy doesn't seem to leave any explicit reference to the BS it uses under its hood.

_jFrame = new JFrame();
build();
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
_jFrame.setSize((int) screenSize.getWidth(), (int) screenSize.getHeight());
StaticGUIUtil.locateOnMiddleOfScreen(_jFrame);
_jFrame.setVisible(true);
// Can't create strategy before making the frame visible - strange, I'd think it was opposite.
BufferStrategy bs = _jFrame.getBufferStrategy();
log.warn("Before:");
log.warn(" BS:" + bs);
if (bs != null) {
DebugStatics.dumpBufferCapabilities(bs.getCapabilities(), "//", LineTake.logWarnLineTaker(log));
}
_jFrame.createBufferStrategy(3);
bs = _jFrame.getBufferStrategy();
log.warn("After:");
DebugStatics.dumpBufferCapabilities(bs.getCapabilities(), "//", LineTake.logWarnLineTaker(log));

gives the following on my log:

[AWT-EventQueue-0] - Before:
8250 [AWT-EventQueue-0] - BS:null
8266 [AWT-EventQueue-0] - After:
8282 [AWT-EventQueue-0] - //BufferCapabilities: FullScreenRequired: false, MultiBufferAvailable: false, PageFlipping: false, FlipContents: null - [java.awt.BufferCapabilities@1f86e79].
8282 [AWT-EventQueue-0] - // FrontBuffer ImageCapabilities: Accelerated:true, TrueVolatile:false - [java.awt.ImageCapabilities@11cfa21].
8282 [AWT-EventQueue-0] - // BackBuffer(s) ImageCapabilities: Accelerated:true, TrueVolatile:false - [java.awt.ImageCapabilities@169be56].

So - Swing doesn't give me access to knowing which BS it actually uses under the hood?

Will my attempt at changing the BS for Swing work?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
stolsvik
Offline
Joined: 2006-09-17
Points: 0

There is no "helpful" or "correct" buttons..

Dmitri Trembovetski

Yes, you're not supposed to have access to Swing's buffer strategy.
In particular, there are cases where Swing doesn't use BS.

Why would you need access to it?

Thanks,
Dmitri

java2d@JAVADESKTOP.ORG wrote:
> Swing's BufferStrategy doesn't seem to leave any explicit reference to the BS it uses under its hood.
>
> _jFrame = new JFrame();
> build();
> Toolkit toolkit = Toolkit.getDefaultToolkit();
> Dimension screenSize = toolkit.getScreenSize();
> _jFrame.setSize((int) screenSize.getWidth(), (int) screenSize.getHeight());
> StaticGUIUtil.locateOnMiddleOfScreen(_jFrame);
> _jFrame.setVisible(true);
> // Can't create strategy before making the frame visible - strange, I'd think it was opposite.
> BufferStrategy bs = _jFrame.getBufferStrategy();
> log.warn("Before:");
> log.warn(" BS:" + bs);
> if (bs != null) {
> DebugStatics.dumpBufferCapabilities(bs.getCapabilities(), "//", LineTake.logWarnLineTaker(log));
> }
> _jFrame.createBufferStrategy(3);
> bs = _jFrame.getBufferStrategy();
> log.warn("After:");
> DebugStatics.dumpBufferCapabilities(bs.getCapabilities(), "//", LineTake.logWarnLineTaker(log));
>
> gives the following on my log:
>
>
> [AWT-EventQueue-0] - Before:
> 8250 [AWT-EventQueue-0] - BS:null
> 8266 [AWT-EventQueue-0] - After:
> 8282 [AWT-EventQueue-0] - //BufferCapabilities: FullScreenRequired: false, MultiBufferAvailable: false, PageFlipping: false, FlipContents: null - [java.awt.BufferCapabilities@1f86e79].
> 8282 [AWT-EventQueue-0] - // FrontBuffer ImageCapabilities: Accelerated:true, TrueVolatile:false - [java.awt.ImageCapabilities@11cfa21].
> 8282 [AWT-EventQueue-0] - // BackBuffer(s) ImageCapabilities: Accelerated:true, TrueVolatile:false - [java.awt.ImageCapabilities@169be56].
>
> So - Swing doesn't give me access to knowing which BS it actually uses under the hood?
>
> Will my attempt at changing the BS for Swing work?
> [Message sent by forum member 'stolsvik' (stolsvik)]
>
> http://forums.java.net/jive/thread.jspa?messageID=298061
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

stolsvik
Offline
Joined: 2006-09-17
Points: 0

> Yes, you're not supposed to have access to Swing's
> buffer strategy.
> In particular, there are cases where Swing doesn't
> use BS.
> Why would you need access to it?

1) Because I want. I want things to be explicit. I don't get why Swing shouldn't install its BufferStrategy explicitly into the JFrame if that is what it uses. I want to know which strategy it is using now. Why is it faster on this screen rather than that machine? etc.

2) Because I maybe want to change it, to see if my particular setup would work better with such or that strategy.

3) I could possibly install a "fake" BufferStrategy, giving all kinds of cool possiblities.

Bottom line: Things are better when there is no magic involved.

Dmitri Trembovetski

java2d@JAVADESKTOP.ORG wrote:
>> Yes, you're not supposed to have access to Swing's
>> buffer strategy.
>> In particular, there are cases where Swing doesn't
>> use BS.
>> Why would you need access to it?
>
> 1) Because I want. I want things to be explicit. I don't get why Swing shouldn't install its BufferStrategy explicitly into the JFrame if that is what it uses. I want to know which strategy it is using now. Why is it faster on this screen rather than that machine? etc.

And from the perspective of an API developer, I don't want you to know =)
The less you know the easier for me to change things if needed
without breaking your code.

> 2) Because I maybe want to change it, to see if my particular setup would work better with such or that strategy.
> 3) I could possibly install a "fake" BufferStrategy, giving all kinds of cool possiblities.

Feel free to install your own Swing RepaintManager and do whatever you
want, then.. You'll have more control over the repainting.

But in general you won't be able to get access to Swing's default
BufferStrategy.

Thanks,
Dmitri

>
> Bottom line: Things are better when there is no magic involved.
> [Message sent by forum member 'stolsvik' (stolsvik)]
>
> http://forums.java.net/jive/thread.jspa?messageID=298144
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".