Java animation, with key listener


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>


"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>


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.


  • Cannot receive notification in iOS [Firebase]
  • Get inline data from serial
  • How to convert @ mention syntax to HTML in a video game app?
  • Lost connection to MySQL server during query on random simple queries
  • mysql_query() expects parameter 2 to be resource, boolean given [duplicate]
  • How to decode base64 tag before (or during) the readfile(“mypage.html”)
  • Rails 3 routes and modules
  • printout webpage with @font-face
  • How do I detect which submit button was pressed on a Zend Framework form?
  • TFS edit build log using custom activity
  • Matplotlib rotate image file by X degrees
  • Capturing HTML Text Input Key press after key has been applied?
  • Chrome breakpoint on radio doesn't fire
  • CKeditor stripping font tags instead of converting to span
  • Android onKey w/ virtual keyboard
  • How do I Dispose a HttpResponseMessage in my Web Api Method?
  • Possible to get mouse events fired when cursor is outside page?
  • Trying to get the char code of ENTER key
  • Using Sax parsing to edit and write XML in VB6
  • Debug.DrawLine not showing in the GameView
  • PHP CURL timing out but CLI CURL works
  • Do I need to reset a Perl hash index?
  • Why querying a date BC is changed to AD in Java?
  • Yii2: Config params vs. const/define
  • Disable Enter in editText android
  • ilmerge with a PFX file
  • Why value captured by reference in lambda is broken? [duplicate]
  • Counter field in MS Access, how to generate?
  • How to check if every primary key value is being referenced as foreign key in another table
  • Javascript + PHP Encryption with pidCrypt
  • Websockets service method fails during R startup
  • python regex in pyparsing
  • Acquiring multiple attributes from .xml file in c#
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • Why joiner is not used after Sequence generator or Update statergy
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • How can I remove ASP.NET Designer.cs files?
  • Recursive/Hierarchical Query Using Postgres
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal