I am wondering about the best way to do a fullscreen doublebuffered application that also uses Swing components. In other words, I want to actively manage drawing, but also have the luxury of not writing my own UI code for buttons, listboxes, etc.
The way I’ve done it so far is to create a Frame with a page flipping buffer strategy, to use setIgnoreRepaint on the frame, add components to it, then explicitly render those components in my render loop along with all my other sprites. I transform the graphics context to the appropriate locations for each component and call paint on the component using my buffer strategy’s graphics context.
It seems to work, but I have doubts. I’ve only tried it using JButtons and haven’t bothered yet with other component types.
Is this a bad idea? Am I spawning new threads by creating and adding these components to my Frame that could come back to haunt me? Is there a better way?
I tried setting up a standard fullscreen Swing application and adding a Canvas to my Frame as one of the components (along with buttons, etc). Then I tried creating a bufferstrategy on just the canvas. This works in windowed mode, but in fullscreen only the Swing components show up. The canvas is blank white and won’t draw anything. I can create a single buffer strategy on the canvas and it works, but of course that looks horrible.