This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JButtons switching states(icons) too quickly

 
A Parent
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple memory game that I've been trying to debug. It allows the user to flip two cards, compares them, if they are a match they stay up, otherwise get flipped back over. Problem is, for the second card flipped, it next does the comparison so quickly, it doesn't seem that the second card was ever displayed.

Any ideas on how to fix this, or is there something I'm missing? I spent most of the day on sun's website trying to figure out threads and sleep vs wait... you can tell I'm not an expert. TIA!

 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove all other thread code, start a new thread inside the 'checkForMatch' method,
begin the run method with the desired delay, proceed with checking...

[ May 18, 2005: Message edited by: Craig Wood ]
 
A Parent
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you! Can't tell you how long I looked at thread samples but wasn't sure how to integrate them into my own code. I also found the Timer method, which worked too.



Now it's not working as I try to convert to an applet, I have changed the constructor to init, removed the setSize, setTitle calls... it's saying there's a Java IO access Permission error? I'll do a little more research and then post a new thread in applets.
[ May 20, 2005: Message edited by: A Parent ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic