@Override
 public void start(Stage primaryStage) throws Exception {
   FXMLLoader loader = new FXMLLoader(getClass().getResource("mainwindow.fxml"));
   loader.load();
   MainWindowController controller = loader.getController();
   controller.setStage(primaryStage);
   VBox root = loader.getRoot();
   Scene scene = new Scene(root);
   primaryStage.setScene(scene);
   primaryStage.show();
 }
Beispiel #2
0
 public Parent getRoot() {
   if (this.root == null) {
     try {
       final URL url = this.getClass().getResource(fxml);
       final FXMLLoader loader = new FXMLLoader(url);
       loader.setController(this);
       loader.load();
       this.root = loader.getRoot();
     } catch (final IOException exception) {
       throw new RuntimeException(exception);
     }
   }
   return root;
 }
  @Nullable
  protected Node loadFromFXML(@Nonnull String baseName) {
    requireNonBlank(baseName, "Argument 'baseName' must not be blank");
    if (baseName.endsWith(FXML_SUFFIX)) {
      baseName = stripFilenameExtension(baseName);
    }
    baseName = baseName.replace('.', '/');
    String viewName = baseName + FXML_SUFFIX;
    String styleName = baseName + ".css";

    URL viewResource = getResourceAsURL(viewName);
    if (viewResource == null) {
      return null;
    }

    FXMLLoader fxmlLoader = new FXMLLoader(viewResource);
    fxmlLoader.setResources(getApplication().getMessageSource().asResourceBundle());
    fxmlLoader.setBuilderFactory(
        new JavaFXBuilderFactory(getApplication().getApplicationClassLoader().get()));
    fxmlLoader.setClassLoader(getApplication().getApplicationClassLoader().get());
    fxmlLoader.setControllerFactory(klass -> getMvcGroup().getView());

    try {
      fxmlLoader.load();
    } catch (IOException e) {
      throw new GriffonException(e);
    }

    Parent node = fxmlLoader.getRoot();

    URL cssResource = getResourceAsURL(styleName);
    if (cssResource != null) {
      String uriToCss = cssResource.toExternalForm();
      node.getStylesheets().add(uriToCss);
    }

    return node;
  }
  public void home_onClick(ActionEvent event) throws IOException {

    if (event.getSource() == home_createOrder) {

      FXMLLoader loader = new FXMLLoader();

      loader.setLocation(getClass().getResource("cwselection_page.fxml"));

      loader.load();

      Parent p = loader.getRoot();

      Scene scene = new Scene(p);

      Stage stage = (Stage) ((Node) event.getTarget()).getScene().getWindow();

      stage.setScene(scene);

      customerWorkerPage np = loader.getController();
      np.initData(shopcontroller, crappyhour);

      stage.show();

    } else if (event.getSource() == home_payOrder) {

      if (!shopcontroller.checkCashierState()) {

        FXMLLoader loader = new FXMLLoader();

        loader.setLocation(getClass().getResource("cashierSelectNotification.fxml"));

        loader.load();

        Parent p = loader.getRoot();

        Stage stage = new Stage();
        stage.setScene(new Scene(p));

        stage.show();
      } else {
        FXMLLoader loader = new FXMLLoader();

        loader.setLocation(getClass().getResource("payOrder_page.fxml"));

        loader.load();

        Parent p = loader.getRoot();

        Stage stage = (Stage) ((Node) event.getTarget()).getScene().getWindow();
        stage.setScene(new Scene(p));

        payOrder po = loader.getController();
        po.initData(shopcontroller, crappyhour);

        stage.show();
      }
    } else if (event.getSource() == home_cashierMenu) {

      FXMLLoader loader = new FXMLLoader();

      loader.setLocation(getClass().getResource("cashierMenu_page.fxml"));

      loader.load();

      Parent p = loader.getRoot();

      Stage stage = (Stage) ((Node) event.getTarget()).getScene().getWindow();
      stage.setScene(new Scene(p));

      cashierMenu cm = loader.getController();
      cm.initData(shopcontroller, crappyhour);

      stage.show();
    } else if (event.getSource() == home_stockerMenu) {

      FXMLLoader loader = new FXMLLoader();

      loader.setLocation(getClass().getResource("stockerMenu_page.fxml"));

      loader.load();

      Parent p = loader.getRoot();

      Stage stage = (Stage) ((Node) event.getTarget()).getScene().getWindow();
      stage.setScene(new Scene(p));

      StockerMenu cm = loader.getController();
      cm.initData(shopcontroller, crappyhour);

      stage.show();
    } else if (event.getSource() == home_charts) {

      FXMLLoader loader = new FXMLLoader();

      loader.setLocation(getClass().getResource("charts_page.fxml"));

      loader.load();

      Parent p = loader.getRoot();

      Stage stage = (Stage) ((Node) event.getTarget()).getScene().getWindow();
      stage.setScene(new Scene(p));

      charts cm = loader.getController();
      cm.initData(shopcontroller, crappyhour);

      stage.show();
    } else if (event.getSource() == home_selectFiles) {

      FXMLLoader loader = new FXMLLoader();

      loader.setLocation(getClass().getResource("selectFile_page.fxml"));

      loader.load();

      Parent p = loader.getRoot();

      Stage stage = (Stage) ((Node) event.getTarget()).getScene().getWindow();
      stage.setScene(new Scene(p));

      selectFiles cm = loader.getController();
      System.out.println(crappyhour);
      cm.initData(shopcontroller, crappyhour);

      stage.show();
    } else if (event.getSource() == home_aboutme) {

      FXMLLoader loader = new FXMLLoader();

      loader.setLocation(getClass().getResource("aboutme_page.fxml"));

      loader.load();

      Parent p = loader.getRoot();

      Stage stage = new Stage();
      stage.setScene(new Scene(p));

      stage.show();
    } else if (event.getSource() == home_update) {

      FXMLLoader loader = new FXMLLoader();

      loader.setLocation(getClass().getResource("update_page.fxml"));

      loader.load();

      Parent p = loader.getRoot();

      Stage stage = new Stage();
      stage.setScene(new Scene(p));

      mainUpdate mu = loader.getController();
      mu.initData(shopcontroller);

      stage.show();
    }
  }