I have had problem like this before. so you are not alone. I made mistakes like this.
Your Problem
while (!enteredField) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Solution
Thread thread = new Thread(() -> {
while (!enteredField) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
thread.start();
* Detailed Response*
' What you did was that you created a thread inside a while loop. Basically You paused the whole GUI for 10 milliseconds, the whole program for matter of fact. Furthermore, I do not understand what your objective is. You said that you want to wait for the user to click on the GUI.Suggestions would be, listen for the button click. for example Button.setOnAction(() -> {}); That would do he job instead of sleeping. I just the only case that you would want to pause or sleep is if you are animating somethings.