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?

