
Question:
I tried to make it so that,if I pressed the right/left key, the sprite/Mario would face right/left. If I pressed the right key, he would face right. But for some reason, When I pressed the left key, he won't face left.
Source Code: <a href="http://pastebin.com/zzRbAVkg" rel="nofollow">First</a> ,<a href="http://pastebin.com/zHH31ntf" rel="nofollow">Second</a>
<a href="http://s1201.photobucket.com/albums/bb356/SubzeroX5/?start=all" rel="nofollow">Images</a>
Answer1:"To fire keyboard events, a component <em>must</em> have the keyboard focus."—<a href="http://download.oracle.com/javase/tutorial/uiswing/events/keylistener.html" rel="nofollow"><em>How to Write a Key Listener</em></a>
Answer2:Don't use a KeyListener. Instead use <a href="http://download.oracle.com/javase/tutorial/uiswing/misc/keybinding.html" rel="nofollow">Key Bindings</a> which are more flexible and are used by all Swing components.