I'm creating a simple game and I'd like to repaint the board after every move. So, after I call move(), what I would like to do is this: (by the way, a View is a JComponent that holds pieces; since the number of pieces has changed after the move, it needs to be repainted)
for(View v : views){
v.repaint();
}
It's not working. When I call repaint()
on a single View, it works fine. I tried using paintImmediately
, and revalidate
, and update
... nothing works within the loop.
Any ideas? Thanks in advance.
EDIT: I should add that repaint() does get called when the window is resized, so I know that View's paintComponent method is valid and works. It's just not being called from the loop. When the debugger steps through the loop, it does not enter repaint() and nothing happens to the screen.