how do i pause my code from inside a switch (java) : <p>I'm trying to make a small game inside a javafx application but the player(image)
moves insanely fast so I tried using a Thread.sleep and TimeUnit.SECONDS.sleep but neither worked.</p>

<p>is it bacause I'm missing an import or the fact that I'm doing this inside a switch statement please help me.</p>

<pre><code>                case W:
                    imgView.setRotate(270);
                    if (imgView.getY() &gt;= 50) {
                        imgView.setY(imgView.getY() - 50);
                        TimeUnit.SECONDS.sleep(1);
                    }
                    break;
</code></pre>
