I would like to know which method should I choose when trying to create an animated game in java. Basically I have a 9×9 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.
One commonly used approach is to call
repaint()from theActionListenerof a SwingTimer.