aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JButtons switching states(icons) too quickly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButtons switching states(icons) too quickly" Watch "JButtons switching states(icons) too quickly" New topic
Author

JButtons switching states(icons) too quickly

A Parent
Greenhorn

Joined: May 18, 2005
Posts: 9
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

Joined: Jan 14, 2004
Posts: 1535
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

Joined: May 18, 2005
Posts: 9
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JButtons switching states(icons) too quickly
 
Similar Threads
Standalone app worked... as Applet does not.
for loop
what layouts to use
method conditions not applying
help~!!!