• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Small problem with method call

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic