Skip to content

Commit

Permalink
Close Window after 1s
Browse files Browse the repository at this point in the history
  • Loading branch information
TianYong-Goh committed Sep 18, 2020
1 parent 514d8d7 commit 7191bab
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/mug/MainWindow.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package mug;

import javafx.animation.PauseTransition;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.util.Duration;

/**
* Controller for MainWindow. Provides the layout for the other controls.
Expand Down Expand Up @@ -62,9 +65,12 @@ private void handleUserInput() {
);
userInput.clear();
if (input.toUpperCase().equals("BYE")) {
userInput.setPromptText("Text field has been disabled. Hope to see you soon!!");
userInput.setDisable(true);
sendButton.setDisable(true);
PauseTransition delay = new PauseTransition(Duration.seconds(1));
delay.setOnFinished(event -> {
Platform.exit();
System.exit(0);
});
delay.play();
}
}
}

0 comments on commit 7191bab

Please sign in to comment.