Now I have a few questions:
Is there an easier way to set the background color of a table cell than
DOM.setStyleAttribute(this.getCellFormatter().getElement(i,j),"backgroundColor","yellow");
?
Why does
DOM.setAttribute(this.getCellFormatter().getElement(i,j),"bgcolor","yellow");
not work? (I tried it, and I think it should work too, but it didn't.)
Could you add a convenience method to HTMLTable like
setBackgroundColor(int row, int col)?
In the application mentioned above, when the user clicks the "Mix me"
button, 100 random moves are executed. I would like to show these moves
as an animation.
Unfortunately, the table is only redrawn once after all 100 moves are
executed.
Is there a way to force the table to redraw after each move?
-Mark
I think you'll find that to have the redraw happen after each move,
you'll need to have a slight delay in execution. In Javascript, this
would be done through 'setTimeout' and in Java, it would be
Thread.sleep(), but I'm not sure what you'd have to do for GWT.
Let me know what works!
Cheers,
Aaron Watkins
---------------------
My Site: http://www.goannatravel.com
I have a suggestion on the last question: try out DeferredCommand.
Each time you get the callback, draw the new state of the board and
then setup the DeferredCommand again to do the next one.
Timer.scheduleRepeating() with a very short timeout might also do what
you want.
Scott
Your DeferredCommand idea worked. Thanks a lot!
Between two commands, however, I had to add an additional
null command to create a pause. So now I make one move,
draw the board, and then add two commands to the queue:
DeferredCommand.add(null);
and
DeferredCommand.add(new MixCommand(board,numMoves-1));
I uploaded the new version to http://dettinger.eu/puzzle/index.html
Mark