.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
.
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.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
"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.