Exemplo n.º 1
0
  /**
   * This method is called when the splash screen has finished initializing the application. The
   * initialized resources are in a ServiceLocator singleton. Our task is to now create the
   * application MVC components, to hide the splash screen, and to display the application GUI.
   *
   * <p>Multitasking note: This method is called from an event-handler in the Splash_Controller,
   * which means that it is on the JavaFX Application Thread, which means that it is allowed to work
   * with GUI components. http://docs.oracle.com/javafx/2/threads/jfxpub-threads.htm
   */
  public void startApp() {
    // Stage appStage = new Stage();
    serverStage = new Stage();
    // Resources are now initialized
    ServiceLocator sl = ServiceLocator.getServiceLocator();
    Translator t = sl.getTranslator();
    System.out.println("BLABLA");
    try {
      final URL fxmlURL =
          getClass().getResource("/Server/Server.fxml"); // FXML-File from the ClientLogin-Window
      final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL);
      fxmlLoader.setController(new Server_Controller());
      final Parent root = fxmlLoader.load();
      Scene scene = new Scene(root, 650, 450);
      //			scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
      serverStage.setScene(scene);
      serverStage.setTitle(t.getString("program.name.windowName"));
      serverStage.show();
      String zwischenstatus = fxmlURL.toString();
      System.out.println("Application FXML Loader Pfad ist: " + zwischenstatus);
    } catch (Exception e) {
      e.printStackTrace();
    }

    // Close the splash screen, and set the reference to null, so that all
    // Splash_XXX objects can be garbage collected
    splashView.stop();
    splashView = null;

    //        view.start();
  }
Exemplo n.º 2
0
  /**
   * The stop method is the opposite of the start method. It provides an opportunity to close down
   * the program, including GUI components. If the start method has never been called, the stop
   * method may or may not be called.
   *
   * <p>Make the GUI invisible first. This prevents the user from taking any actions while the
   * program is ending.
   */
  @Override
  public void stop() {
    if (serverStage != null) {
      // Make the view invisible
      // Commented because of errors - serviceLocator.getLogger().info("Server-GUI wird beendet");
      // // HIIIER Kommt wohl kein check durch - ist es wirklich view den wir prüfen müssen??
      serverStage.hide();
    }
    if (serverStage != null) {
      Platform.exit(); // Ends all JavaFX activities
      System.exit(0); // Ends all Programm activities
    }

    serviceLocator.getLogger().info("nach dem if vom Server_Template stopp");
    serviceLocator
        .setChangeValueWindowIsActive(); // Changes the ServiceLocator Value for WindowIsActive to
    // false so that the thread ShowTimeInWindow() stops

    // More cleanup code as needed

    serviceLocator
        .getLogger()
        .info("Application terminated"); // Wieso wird diese Message jetzt mit "appStage.hide();"
    // nicht mehr angezeigt?
  }