KeyListener problem with Window Deactivation

I have a game that a player is moving around the JFrame using a keyListener. However i have this weird problem. When i am pressing the key (mean continously down never release) and deactivate the window frame, the player move by itself in the background. I tried stopping the keypressed event by using a if else boolean. It do stop when the frame is deactivated, but when it is activated, it continue to move by itself . The strange thing is that i have to press the 4 direction button anyhow to make the player stop.

Anybody with similar error?

[558 byte] By [Hanz_05a] at [2007-11-27 11:09:08]
# 1

Just a thought, you could add a WindowFocusListener to the frame and implement the windowLostFocus method to stop the player moving.

floundera at 2007-7-29 13:33:31 > top of Java-index,Java Essentials,Java Programming...