No Keyboard After Making a JFrame?

Started by elias4444, August 04, 2008, 18:15:31

Previous topic - Next topic

elias4444

This is weird issue I just ran into. My application first makes a JFrame to help the user setup options and to register the game. When the user clicks the "Start" button, I dispose of the JFrame and launch the actual game. However, when I do it this way, the Keyboard doesn't register any key presses. If I skip making the JFrame, then everything works fine.

Any ideas?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias4444

BTW... There IS a workaround for this, I know:

You loop on the condition (while jframe.isVisible()), and once the condition fails, launch your game. I'm just wondering why you can't just launch your game from the JFrame? I'm guessing it has to do with threading or something, but would like a solid answer.

Thanks.  :)
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Fool Running

Does it work if you hide the JFrame instead of just calling dispose() on it?
Or if you hide it, then dispose of it?

EDIT: Is it possible that the game window does not have focus (and thus does not recieve any events) because the OS was giving focus to something else as the JFrame got disposed? I've seen similar problems (non-LWJGL) when trying to close a window that created another window as the new window is coming up. Maybe try calling Display.update() before you dispose of the JFrame, but after you bring up the display?
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

elias4444

Tried all of those actually.  :P

Really, it's the oddest thing.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com