In my Java game, I can’t get the buttons to work consistently WITH the button clicks. My program works fine on my MAC but doesn’t work OK with Windows. Any suggestions?
It’s probably an issue with the keyboard focus. Look up focus management in the Java Tutorial.
Basically, you need to make everything you can ignore the focus. And then make the container components all add your KeyListener. Or at least that’s the normal thing to do - it might not be best for your particular program.
Well, focus issues are usually fixed when you click In the window I think. My framework doesn’t handle it properly either, but hte first screen you see uses desguised swing buttons so it gets focus when you click those :D.
requestFocusInWindow() in your JFrame I think, again mine doesnt even work.
requestFocus() in your canvas type doodad
correct me if I am wrong…
Or you could kick this whole focus issue in the nuts and use JInput.