.
Printable View
.
Flickering can be caused by a great number of things, more often than not it can be due to incorrectly drawing to a JPanel (assuming you are doing this - as your post doesn't mention anything about Swing). Post an SSCCE to clarify the issue and demonstrate the flickering.
Sorry, but that's not an SSCCE- an SSCCE should be short, self-contained, compilable, and an example of what's happening to you. It's really hard for us to troubleshoot a problem without an SSCCE. Including all your code is definitely overkill, so I recommend you narrow it down and eliminate everything that's not directly related to the problem. For example, stop drawing one of your on-screen items. Does the problem still persist? Then take out another one. Continue that process until you've narrowed it down to a single problem.
That being said, what is the point of redrawing everything in a loop? That definitely sticks out to me as something that could cause the behavior you described.
"Long SSCCE" is an oxymoron.
You've got 3 nested loops in your paintComponent...anything with this many nested loops will take some time. If you are animating, make sure you are not making calls to getGraphics and all things are dispatched to the EDT (you did not post anything of the sort, which is why I asked for a SSCCE)
From what you posted I can fathom a guess your paintComponent is clogging up given it is taking a while to draw. You can test this by profiling your paintComponent (print out how long it takes to draw) or removing some lines of code to see if this helps. If either tells you the method is just taking too long, you will need to optimize your drawing in one way or another.