It sounds like you are doing too much on Dispatch Event (EDT). AWT-Event-Queue-0 looks like an EDT. Also, your last comment says
... it seems that the lag only happens when I draw my game panel first on the image, and not directly on the component.
You will need to push some of your calculations to other threads, and it seems that drawing the playing field is a good choice for this. In addition, any AI that you have.
Keyboard and mouse handlers run on EDT, and graphics updates are also needed. But you can pre-render the image (as you are doing now) outside of EDT. And you can send keyboard and mouse events to another thread through BlockingQueue.
Another thing you could do is to cancel the refresh rate of your game from the frame refresh rate.
But without any details, I cannot give more advice.
Update : (just read your bit about ConcurrentModificationException )
This can be caused in two different ways:
- You are updating the collection (for example, ArrayList) in a different thread from the one in which you are reading it; or
- you repeat this assembly and update it in a loop.
Point 2 is easy to fix; but I am afraid that I cannot teach the safety of flows in such a short space.
source share