问题
I am trying to make a Swing application which renders in full screen, following the description here http://download.oracle.com/javase/tutorial/extra/fullscreen/exclusivemode.html and the source code here http://download.oracle.com/javase/tutorial/extra/fullscreen/example-1dot4/DisplayModeTest.java
This works quite well, however as soon as I drop in a GLCanvas object as one of the components of the frame, all that shows up is a black screen. Exiting full screen, I can see the OpenGL image for a moment at full screen, then it shows up fine again in a window. Even though nothing is being displayed, I can interact with the swing components, like buttons, as if they were.
It seems to me almost like another blank buffer is being drawn above the actual swing app, but I can't figure out why that would be. Alternatively, I wonder if it's not an issue with the full screen being handled by the graphics card which is also handling JOGL?
I don't need the hardware accelerated full screen, though it might be nice - if this is unresolvable, is there some more robust way to implement full screen in a Java app?
回答1:
Try disabling -Dsun.java2d.noddraw=true
as this FAQ says.
回答2:
You cannot call setUndecorated(...) on a displayable window, you have to dispose it first but this will dispose the canvas too. Use a shared drawable to do this and remove it before calling dispose() on the frame.
来源:https://stackoverflow.com/questions/4245060/full-screen-swing-with-jogl