0

I'm new to java and i decided to make this game http://www.brainmetrix.com/memory-game/. My idea was to make grid of JButtons, and when a JButton is clicked I'll delete it and replace it with a JLabel of an image in the grid. My problem is that when the user clicks on two buttons and they don't match, the program should make the two images appear for a second or so (pause), and then the images should be deleted and replaced with buttons. To pause I used: TimeUnit.SECONDS.sleep(1), but this didn't make the two images appear (image: https://i.stack.imgur.com/RHqsZ.png) - it took the shape of the clicked button without replacing it with the image.

helencrump
  • 1,351
  • 1
  • 18
  • 27
  • 2
    I would use a field of `JToggleButton`, so you can nicely show what was selected and if the two chosen tiles match you replace them, otherwise you toggle back to the original state. – maraca Jun 25 '15 at 16:03
  • I think [this](http://stackoverflow.com/a/2258080/5044950) is what you want. – Sam Estep Jun 25 '15 at 16:05

0 Answers0