Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Small problem with method call

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a small problem with my rubiks cube.
I want the cube to have all its played moves reversed.

I have a method "undoLastMove()", which graphically undoes a twist applied.
So when I press "Undo" button, this method is called, and everything works fine.

But I also have an "Undo All" button, which basically needs to call that method N times.
But if I do:

It causes a horrible mess, since it doesn't wait for one twist to complete before starting the other, which is what I expected, since they are graphical so they run on AWT thread, I think its called.

I've tried using SwingUtilities.invokeAndWait(Runnable runnable), but I still doesn't work, is there a good way to solve this?

Thanks
[ April 14, 2007: Message edited by: colin shuker ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you want to see all the undo's?

if so, use a javax.swing.Timer
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, why didn't I think of that.
I had just started to do it recursively. eg

But this is causing a few complications, I think a timer should work well.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm, still can't get it to work right, I don't really want a 1 second gap between each undo, but if I set it to say 50ms, then it doesn't complete the first turn in time, since it starts the next turn 50ms later.

Perhaps I need to do it recursivley within the timer somehow?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic