How to create a delay in Swing

后端 未结 4 755
长情又很酷
长情又很酷 2020-11-30 14:49

I made a blackjack game, and I want the AI player to pause between taking cards. I tried simply using Thread.sleep(x), but that makes it freeze until the AI player is done t

4条回答
  •  借酒劲吻你
    2020-11-30 15:46

    so I looked at Timers, but I could not understand how I could use one for this

    The Timer is the solution, since as you say you are updating the GUI which should be done on the EDT.

    I'm not sure what your concern is. You deal a card and start the Timer. When the Timer fires you decide to take another card or hold. When you hold your stop the Timer.

提交回复
热议问题