I'm making a side-scrolling shooter, and I've successfully implemented resolution change and windowed/fullscreen-mode changing. Only problem is, very rarely the screen goes black when I change to windowed mode. I end up with a black fullscreen window, I have my custom cursor and if I Alt-Tab I can see from the little preview Windows 7 gives me at the taskbar, that the menu is being shown in my game, but when I enter it again it is still black, with the cursor. Then I click where I think the "Apply" button is, and it changes to the correct windowed resolution WITH my menus being shown.

It's really weird, and I think it might have something to do with my brute-force way of changing the displaymode. Could someone tell me what might be causing this?

The if-statements are there, because I use these functions to set the screen windowed/full-screen depending on settings loaded from a configuration-file when the game starts. So the if-statements are skipped when the game starts, but if the settings are changed within the options-menu, it'll transfer the current input-handlers and cursor from the window to the full-screen frame and vice versa.

I have separate methods for changing resolutions for windowed mode and full-screen mode respectively, when the windowed-mode flag has not been changed in the options menu, and those work just fine.

Well, I know it's wrong to bump , but I've yet to find a fix for this. I've tried so many things by now, and I just can't stop this from happening on rare occasions. Sometimes it's on first try, and sometimes I have to do it 40 times before it happens, but it always does eventually.

Please, someone with intricate knowledge of the way the graphics environment for 2D works, help me. Many medals will come in an answer's wake

Otherwise, if things only sometimes fail, it results often from incorrect threading.

Yeah, maybe I should put the game in a state where nothing is updated or drawn until the change has been achieved. It's just that this is all called from one controller-class, so it should never trip over itself. The changes should be executed completely linearly.

never hurts to print or dump the error into a file for exceptions such as those.

I'll definitely do that, and see if it ever fails.

In conclusion, it could well be all these three rather simple things. Thank you very much for your inputs. I guess I have an evening of destroying my graphics adapter in front of me XDI'll post back if I find a solution that keeps the weirdness away.

I can't get this to work! If I use just 1 frame, and change that between being fullscreen and windowed, either the windowed state wont draw anything, or the change to fullscreen doesn't work. I can get one state to work at a time.

*heart breaking*

Why?! It works fine using the pastebin'ed-way, except for that small little thing. I can't even get it to spit out any errors or anything. I've scattered messages all over, wherever it could possibly return a null or something unusable (that's quite a few places!), and none report back to me when it happens. And the weirdest thing is, when I get the black screen and Alt-Tab out, the Windows taskbar taunts me by showing a preview of my application correctly displaying the graphics...WTF?!

I'm tempted to just leave it there...but it's the basis of the game. It's the ScreenManager-class... I have to use this for all my games. And it's being picky.

One other thing. Have you downloaded your most recent graphic drivers?

Well, not the absolutely newest, but they're not more than a couple of months old. It IS a laptop, though. Geforce 525M /w 1024mb. But surely that can't be it. But good point, nonetheless; check the hardware. I shall have to test on my desktop computer

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org