diff options
Diffstat (limited to 'src/main/java/com/mavlushechka/notaryqueue/NotaryQueueApplication.java')
-rw-r--r-- | src/main/java/com/mavlushechka/notaryqueue/NotaryQueueApplication.java | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/main/java/com/mavlushechka/notaryqueue/NotaryQueueApplication.java b/src/main/java/com/mavlushechka/notaryqueue/NotaryQueueApplication.java new file mode 100644 index 0000000..29605ea --- /dev/null +++ b/src/main/java/com/mavlushechka/notaryqueue/NotaryQueueApplication.java @@ -0,0 +1,83 @@ +package com.mavlushechka.notaryqueue; + +import com.mavlushechka.notaryqueue.controller.HelperController; +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.fxml.JavaFXBuilderFactory; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.io.IOException; +import java.net.URL; +import java.util.Objects; + +public class NotaryQueueApplication extends Application { + + + public static NotaryQueueApplication instance; + private Stage stage; + + + public static void main(String[] args) { + launch(); + } + + public NotaryQueueApplication() { + instance = this; + } + + @Override + public void start(Stage stage) throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(NotaryQueueApplication.class.getResource("main.fxml")); + Scene scene = new Scene(fxmlLoader.load(), 600, 400); + + stage.setScene(scene); + stage.show(); + this.stage = stage; + } + + public void setNotaryScene() { + try { + setScene(NotaryQueueApplication.class.getResource("notary.fxml")); + } catch (IOException ioException) { + throw new RuntimeException(ioException); + } + } + + public void setHelperScene() { + try { + setScene(NotaryQueueApplication.class.getResource("helper.fxml")); + } catch (IOException ioException) { + throw new RuntimeException(ioException); + } + HelperController.instance.setContextMenuToClientListViews(); + HelperController.instance.loadClientsToListViews(); + HelperController.instance.receiveUpdates(); + } + + public void setMonitorScene() { + try { + setScene(NotaryQueueApplication.class.getResource("monitor.fxml")); + } catch (IOException ioException) { + throw new RuntimeException(ioException); + } + HelperController.instance.isMonitorScene = true; + HelperController.instance.loadClientsToListViews(); + HelperController.instance.receiveUpdates(); + } + + private void setScene(URL fxml) throws IOException { + Parent parent = FXMLLoader.load(Objects.requireNonNull(fxml), null, new JavaFXBuilderFactory()); + Scene scene = stage.getScene(); + + if (scene == null) { + scene = new Scene(parent, 1280, 720); + stage.setScene(scene); + } else { + stage.getScene().setRoot(parent); + } + stage.sizeToScene(); + } + +}
\ No newline at end of file |