Adding animation for a series of moves
I am keeping a deck of cards, as imageIcons in JLabels, as laid out on a JLayeredPane. I have just discovered that moving a card in the event dispatch thread slowly across the screen doesn't have any repainting in it (even with repaint() and vaildate() and all of this).
I have my existing code. There are various legal play types, and each makes calls to move cards when it is time to make a play. Currently, a move simply changes the location of a card. A single play, however, could involve up to two moves and two flips. I will also want a little animation in the flips. So I am in my playType code, say, and I want to issue a few commands, in series, to cause animation of one thing at a time, then the next, and then done.
I can't have the user being able to click on anything until the animation is done. I could skip mouse listeners on cards while animation is flagged.
The thing is, the playType "makePlay()" function is where the controller is. I have a dozen PlayType subclasses, each of which knows a series of moves and flips of its own. Such a controller function needs to be able to issue a series of animation requests (and then be done).
How should I approach this? Should I make a "List" of moves, and then have those moves being executed by events I fire to myself? Can I make a component of some kind that I just use to fire events to myself? My PlayType classes have no sense of the GUI, and do not have gui controls. They reference the "board", which has rows and columns of CardStack objects. Then their makePlay() and makeReversePlay() functions make calls to move and flip cards.
TIA, and cheers -