Reputation: 2106
I would like to know which method should I choose when trying to create an animated game in java. Basically I have a 9x9 matrix; some of the slots of the matrix are filled with 2D figures such as hexagons or circles. some of the figures are moved to different slots or are animated (rotation when clicked or resizing..).
My question would be, in this case should I use only paint() and repaint() to simulate the animation and movement of the figures(in this case I would have to redraw every time the static elements of the matrix?) or is it recommended to use threads and the runnable interface.
I hope my question isn't too vague. I'm looking forward to your advice.Thanks.
Upvotes: 1
Views: 850
Reputation: 168845
One commonly used approach is to call repaint()
from the ActionListener
of a Swing Timer
.
Upvotes: 2