I have a JavaFx application in which I display an alert box using:
alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle(\"Title\");
alert.setHeaderText(
It's closing opened dialog in 2 second.
dialog = new Dialog<>();
dialog.setTitle("It's a dialog!");
dialog.show();
Thread newThread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
Platform.runLater(new Runnable() {
@Override
public void run() {
dialog.close();
}
});
}
});
newThread.start();