Java game development image animation
swordTime appears to be a constant and should therefore be:

private static final int SWORD_TIME = 250;




ImageIcon i = new ImageIcon("/Users/myName/Desktop/FarthornPics/charAttacking.png");


Creating a new ImageIcon each time it is rendered is a big fat waste of resources. Create it once, outside the render method, and only refer to it from inside - just as you have done with charImage.

Additionally, as I doubt that path exists on all computers, I would recommend using a relative path or use classpath resources (possibly with the Maven tool).



Thread.yield();


I have to admit that this is the first time ever that I have seen that method being called. When reading the documentation for this method, it seems there is a good reason for why I have never encountered it before.


  It is rarely appropriate to use this method. It may be useful for debugging or testing purposes, where it may help to reproduce bugs due to race conditions. It may also be useful when designing concurrency control constructs such as the ones in the java.util.concurrent.locks package.


I strongly doubt calling this method is any useful for you.



When doing animations, it is helpful if you know the platform you are doing them on. I have to say that Swing is not the most helpful platform to do animations on. There are a couple of tutorials out there for how to do it. What I am mostly noticing in your code is that you don't seem to call repaint or anything like it anywhere, which makes me a bit surprised that this actually works at all.

If you are developing with Java 8, I think you would benefit from using JavaFX which has better support for animations.

If you are interested in developing games with Java, I would strongly recommend using the framework LibGDX.