public boolean showChapitreAddDialog(Chapitre chapitre, int id) {
    try {
      // Load the fxml file and create a new stage for the popup dialog.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(MainApp.class.getResource("/fxml/addChapitre.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Ajouter un Cours");
      dialogStage.initModality(Modality.APPLICATION_MODAL);
      dialogStage.initStyle(StageStyle.UTILITY);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the cours into the controller.
      AddChapitreController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setChapitre(chapitre, id);

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();

      return controller.isOkClicked();
    } catch (IOException e) {
      e.printStackTrace();
      return false;
    }
  }
 public void initPanel() throws IOException {
   setHasInstance(true);
   FXMLLoader loader = new FXMLLoader(getClass().getResource("../view/checkOut.fxml"));
   Parent root = loader.load();
   checkoutStage.setTitle("CheckOut");
   checkoutStage.setScene(new Scene(root, 600, 400));
 }
  private void showObjectifDialog(int id) {
    try {
      // Load the fxml file and create a new stage for the popup dialog.
      System.out.println("hello");
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(MainApp.class.getResource("/fxml/displayObjectif.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Objectif");
      dialogStage.initModality(Modality.APPLICATION_MODAL);
      dialogStage.initStyle(StageStyle.UTILITY);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the cours into the controller.
      DisplayObjectifController control = loader.getController();
      control.setDialogStage(dialogStage);
      control.setObjectif(id);

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public MainStageController(Controller controller) {
    this.controller = controller;
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainStage.fxml"));
    fxmlLoader.setController(this);
    try {
      root = fxmlLoader.load();
    } catch (IOException e) {
      e.printStackTrace();
    }

    currentUserMenuButton.setText(controller.getCurrentUser().getName());
    collectAccountTable();
    accountsTable
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            new ChangeListener<Account>() {
              @Override
              public void changed(
                  ObservableValue<? extends Account> observable,
                  Account oldValue,
                  Account newValue) {
                controller.setCurrentAccount(accountsTable.getSelectionModel().getSelectedItem());
                showRecords(controller.getCurrentAccount());
                showBalanceLabel();
              }
            });

    showRecords(controller.getCurrentAccount());
    showBalanceLabel();
  }
  /**
   * 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();
  }
示例#6
0
  public PasswordRetryDialogController showPasswordDialog(String username, String failureMessage) {
    try {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(
          TRLauncher.class.getResource("view/passworddialog/retry/PasswordRetryDialog.fxml"));

      AnchorPane pane = loader.load();

      Stage dialogStage = MiscUtils.addIcons(new Stage());
      dialogStage.setTitle("Login (Retry)");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(pane);
      dialogStage.setScene(scene);

      PasswordRetryDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setUsername(username);
      controller.setFailureMessage(failureMessage);

      dialogStage.showAndWait();

      return controller;

    } catch (IOException e) {
      TRLauncher.log.error("Couldn't find the specified layout");
      TRLauncher.log.catching(e);
      Issues.create(null, e);
      return null;
    }
  }
  @FXML
  public void ProductDetails() {

    try {
      URL location = getClass().getResource("proTableview.fxml");

      FXMLLoader fxmlLoader = new FXMLLoader();
      fxmlLoader.setLocation(location);
      fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

      Parent root1 = (Parent) fxmlLoader.load(location.openStream());

      proTableViewController ctr = (proTableViewController) fxmlLoader.getController();

      Scene scene = new Scene(root1);

      RuwanBook.getStage().setTitle("Product Details");
      RuwanBook.getStage().setScene(scene);

      RuwanBook.getStage().show();

    } catch (IOException ex) {
      Logger.getLogger(SupplierController.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
示例#8
0
 protected void initUI(
     String stageTitle,
     String gui,
     double stageWidth,
     double stageHeight,
     double maxStageWidth,
     double maxStageHeight,
     double stageX,
     double stageY,
     boolean resizable,
     Modality modality,
     Stage stage,
     Window owner)
     throws IOException {
   FXMLLoader loader = new FXMLLoader(getClass().getResource(gui));
   loader.setController(this);
   this.scene = new Scene(loader.load(), stageWidth, stageHeight);
   this.stage = (null != stage) ? stage : new Stage();
   this.stage.setMaxWidth(maxStageWidth);
   this.stage.setMaxHeight(maxStageHeight);
   this.stage.setTitle(stageTitle);
   this.stage.setScene(this.scene);
   this.stage.setX(stageX);
   this.stage.setY(stageY);
   this.stage.resizableProperty().setValue(resizable);
   if (null != modality) this.stage.initModality(modality);
   if (null != owner) this.stage.initOwner(owner);
 }
示例#9
0
  public boolean showDbConnectDialog() {
    try {
      // Load the fxml file and create a new stage for the popup dialog.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(Main.class.getResource("view/DbConnectDialog.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Під'єднання до БД");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the person into the controller.
      sample.view.DbConnectDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setConnectField();

      // Set the dialog icon.
      dialogStage.getIcons().add(new Image("file:resources/images/edit.png"));

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();

      return controller.isOkClicked();
    } catch (IOException e) {
      e.printStackTrace();
      return false;
    }
  }
  /**
   * Instancie un controleur secondaire pour la fenetre de consultation du mot à consulter
   *
   * @return
   */
  private Stage loadConsultation() {
    Stage stageConsultation = null;
    FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("../dictionnaire_mot.fxml"));

    VBox rootConsultation = null;

    try {
      rootConsultation = (VBox) fxmlLoader.load();
      FXMLController_2 subController = (FXMLController_2) fxmlLoader.getController();

      subController.setController(this);
      subController.setMotAConsulter(model.motSelectionne);
      subController.setImage();
      subController.init();

      Scene sceneConsultation = new Scene(rootConsultation);
      stageConsultation = new Stage();
      stageConsultation.setScene(sceneConsultation);
      stageConsultation.setTitle("Consultation");

      setConsultWindowCloseHandler(stageConsultation, subController);

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return stageConsultation;
  }
示例#11
0
  public DownloadDialogController showDownloadDialog(Modpack modpack) {
    try {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(TRLauncher.class.getResource("view/downloaddialog/DownloadDialog.fxml"));

      AnchorPane pane = loader.load();

      Stage dialogStage = new Stage();
      dialogStage.setTitle("Downloading Modpack");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(pane);
      dialogStage.setScene(scene);

      DownloadDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setModpack(modpack);

      controller.setDownloadingLabelText("Downloading " + modpack.getDisplayName());

      dialogStage.show();

      try {
        Thread.sleep(4000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      return controller;
    } catch (IOException e) {
      System.err.println("Couldn't find the specified layout");
      e.printStackTrace();
      return null;
    }
  }
  /**
   * Shows the progress dialog and start the progress of all the tasks while reading the file
   *
   * @param file
   */
  public void showProgressDialog(File file) {

    try {
      // Load the fxml file and create a new stage for the popup dialog.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(SolarSizerAppMain.class.getResource("view/ProgressWindow.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      progressDialogStage = new Stage();
      progressDialogStage.setTitle("Working...");
      progressDialogStage.initModality(Modality.WINDOW_MODAL);
      Scene scene = new Scene(page);
      progressDialogStage.setScene(scene);

      // Set the person into the controller.
      ProgressDialogController controller = loader.getController();
      controller.setFile(file);
      controller.setDataProcessedListener(this);
      // Show the dialog and wait until the user closes it
      progressDialogStage.show();
      // calls to process data
      controller.processData();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
示例#13
0
  public StageLoader(String xmlPath, boolean isMainStageOwner) {
    try {
      FXMLLoader loader =
          new FXMLLoader(new File(Utils.getFullPath("./ui/" + xmlPath)).toURI().toURL());
      Parent root = loader.load();
      controller = loader.getController();

      Scene scene = new Scene(root);
      setScene(scene);

      if (isMainStageOwner) {
        initModality(Modality.NONE);
        initOwner(SingleObject.mainStage.getScene().getWindow());
      }

      getScene()
          .addEventHandler(
              KeyEvent.KEY_PRESSED,
              t -> {
                if (t.getCode() == KeyCode.ESCAPE) {
                  LogFiles.log.log(Level.INFO, "Exit " + getTitle());
                  ((Stage) ((Scene) t.getSource()).getWindow()).hide();
                } else if (t.getCode() == KeyCode.ENTER) {
                  runOnEnter(method);
                }
              });
    } catch (IOException e) {
      LogFiles.log.log(Level.SEVERE, e.getMessage(), e);
    }
  }
  @Override
  public IceApplicationProvider.IceApp create(ApplicationContext parentContext) throws IOException {
    FXMLLoader loader = new FXMLLoader(VitalMonitoring.class.getResource("VitalMonitoring.fxml"));
    final Parent ui = loader.load();
    final VitalMonitoring vitalMonitoring = loader.getController();
    vitalMonitoring.setup();

    return new IceApplicationProvider.IceApp() {

      @Override
      public IceApplicationProvider.AppType getDescriptor() {
        return PCAViz;
      }

      @Override
      public Parent getUI() {
        return ui;
      }

      @Override
      public void activate(ApplicationContext context) {
        VitalModel vitalModel = (VitalModel) context.getBean("vitalModel");
        vitalMonitoring.setModel(vitalModel);
      }

      @Override
      public void stop() {
        vitalMonitoring.setModel(null);
      }

      @Override
      public void destroy() {}
    };
  }
  /**
   * Switches scenes
   *
   * @param fxml
   * @param obj
   * @throws Exception
   */
  public static void replaceSceneContent(String fxml, Object obj) throws Exception {

    FXMLLoader loader = new FXMLLoader();

    try {

      loader = new FXMLLoader(SpaceTraderMain.class.getResource(fxml));
    } catch (Exception e) {

    }
    try {
      loader.setController(obj);

    } catch (Exception e) {
      System.out.println(e);
    }
    Parent page;
    page = (Parent) loader.load();

    Scene scene;
    scene = mystage.getScene();

    if (scene == null) {
      scene = new Scene(page, 700, 450);
      // scene.getStylesheets().add(SpaceTraderMain.class.getResource("demo.css").toExternalForm());
      mystage.setScene(scene);
    } else {
      mystage.getScene().setRoot(page);
    }
    mystage.sizeToScene();

    // return page;

  }
示例#16
0
  private void initialiseEditConnectionsWindow() {
    // This is a dirty way to reload connection settings :) possibly could be removed if all
    // connections are closed before loading a new config file
    if (editConnectionsController != null) {
      eventManager.deregisterConnectionStatusObserver(editConnectionsController);
    }

    final FXMLLoader loader =
        FxmlUtils.createFxmlLoaderForProjectFile("EditConnectionsWindow.fxml");
    final AnchorPane connectionWindow = FxmlUtils.loadAnchorPane(loader);
    editConnectionsController = ((EditConnectionsController) loader.getController());
    editConnectionsController.setMainController(this);
    editConnectionsController.setEventManager(eventManager);
    editConnectionsController.setConnectionManager(connectionManager);
    editConnectionsController.setConfigurationManager(configurationManager);
    editConnectionsController.init();

    Scene scene = new Scene(connectionWindow);
    scene.getStylesheets().addAll(mainPane.getScene().getStylesheets());

    editConnectionsStage = new Stage();
    editConnectionsStage.setTitle("Connection list");
    editConnectionsStage.initModality(Modality.WINDOW_MODAL);
    editConnectionsStage.initOwner(getParentWindow());
    editConnectionsStage.setScene(scene);
  }
  @Override
  @FXML
  protected void abrirModalCreate() {
    try {
      // Carrega o arquivo fxml e cria um novo stage para a janela popup.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(getClass().getResource("fxml/dialog/dialogFuncionario.fxml"));
      GridPane page = (GridPane) loader.load();

      // Cria o palco dialogStage.
      Stage dialogStage = new Stage();
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(ControllerTelas.stage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Define a pessoa no controller.
      DialogController<Funcionario> controller = loader.getController();
      controller.setTipe(DialogController.CREATE_MODAL);
      controller.setDialogStage(dialogStage);
      dialogStage.setTitle(controller.getTitulo());
      dialogStage.setResizable(false);
      // Mostra a janela e espera até o usuário fechar.
      dialogStage.showAndWait();

      tabela.getItems().clear();
      atualizarLista();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  @Override
  public void start(Stage stage) throws Exception {

    FXMLLoader LOADER = new FXMLLoader(getClass().getResource("/view/createServer.fxml"));

    // Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml")); -- original LOC
    // when framed

    Parent root = (Parent) LOADER.load();

    createServer_controller_no_use controller =
        (createServer_controller_no_use) LOADER.getController();

    controller.init(stage);

    Scene scene = new Scene(root);

    // stage.initStyle(StageStyle.UNDECORATED); -- Not to use all 3 buttons ->min,max,close
    // stage.initStyle(StageStyle.UTILITY); -- Only use close not min and max
    stage.resizableProperty().setValue(Boolean.FALSE); // Use min and close not max
    stage.setTitle("Jishnu Offline Typeracer");
    stage.setScene(scene);
    stage.getIcons().add(new Image("file:pics/server.png"));
    stage.show();
  }
示例#19
0
  public static void showArchives(Stage s) {
    try {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(ShowArchives.class.getResource("./fxml/archiveView.fxml"));

      Parent root = (Parent) loader.load();
      ShowArchives section = loader.getController();

      Scene scene = new Scene(root);

      Stage stage = new Stage();
      stage.setScene(scene);
      section.setParent(stage);
      section.loadInfo();

      stage.initOwner(s);
      stage.initModality(Modality.APPLICATION_MODAL);
      stage.setResizable(false);
      stage.initStyle(StageStyle.UTILITY);

      stage.showAndWait();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
示例#20
0
 public Controller(Main main, ResourceBundle bundle) throws IOException {
   this.main = main;
   URL location = new URL("file:ui/jfx/main.fxml");
   FXMLLoader fxmlLoader = new FXMLLoader(location, bundle);
   fxmlLoader.setController(this);
   fxmlLoader.load();
 }
  /** Opens the filter window to enable filters. */
  public boolean filters() {
    try {
      String filters = "/java_ebook_search/view/FiltersView.fxml";
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(getClass().getResource(filters));
      AnchorPane page = loader.load();
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Filters");
      dialogStage.initModality(Modality.APPLICATION_MODAL);
      dialogStage.setResizable(false);
      dialogStage.initOwner(searchView.getParent().getScene().getWindow());
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the Filter into the controller.
      FiltersController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      if (null != filter) {
        controller.setFilter(filter);
      }

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();
      // Set Filters
      this.filter = controller.getFilter();

      // Trigger search
      search();
      return controller.isOkClicked();
    } catch (IOException | ParseException e) {
      e.printStackTrace();
      return false;
    }
  }
  public void onFilterActivated() {
    try {
      FXMLLoader filterDialogFile =
          new FXMLLoader(MainApp.class.getResource("view/FilterDialog.fxml"));
      ResourceBundleService.setResourceBundle(filterDialogFile);
      AnchorPane anchorPane = filterDialogFile.load();

      Stage stage = new Stage();
      stage.setResizable(false);
      stage.setTitle(_resources.getString("filter.dialog.title"));
      stage.getIcons().add(_mainApp.getApplicationIcon());
      stage.initModality(Modality.WINDOW_MODAL);
      stage.initOwner(_mainApp.getPrimaryStage());

      stage.setScene(new Scene(anchorPane));

      FilterDialogController controller = filterDialogFile.getController();
      controller.setMainApp(_mainApp);
      controller.setOwner(stage);

      stage.showAndWait();
    } catch (IOException ioEx) {
      ExceptionDialog.show(
          _resources.getString("app.error.dialog.title"),
          _resources.getString("app.error.dialog.header"),
          _resources.getString("app.error.dialog.content.filter"),
          ioEx,
          _mainApp);
    }
  }
示例#23
0
  public String showSetUsernameDialog() {
    try {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(TRLauncher.class.getResource("view/account/SetUsername.fxml"));

      AnchorPane pane = loader.load();

      Stage dialogStage = MiscUtils.addIcons(new Stage());
      dialogStage.setTitle("Add Account");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(pane);
      dialogStage.setScene(scene);

      SetUsernameController controller = loader.getController();
      controller.setDialogStage(dialogStage);

      dialogStage.showAndWait();

      return controller.getUsername();

    } catch (IOException e) {
      TRLauncher.log.error("Couldn't find the specified layout");
      TRLauncher.log.catching(e);
      Issues.create(null, e);
      return null;
    }
  }
  public void showEditDistanceDialog(String selectedText) {
    try {
      // Load the fxml file and create a new stage for the popup
      FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/EditDistanceLayout.fxml"));
      VBox page = (VBox) loader.load();
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Calculate Edit Distance");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set reference to stage in controller
      EditDistanceDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setMainApp(this);
      controller.setField(selectedText);

      // give controller reference to scene (cursor)

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();

    } catch (IOException e) {
      // Exception gets thrown if the fxml file could not be loaded
      e.printStackTrace();
    }
  }
 // Loads the appropriate layout for the pane
 private void loadNode(String tab) {
   Node node;
   getChildren().clear();
   try {
     if (tab.equals("Web")) {
       node =
           (Node)
               FXMLLoader.load(
                   getClass().getResource("resource/website/view/website_viewpane.fxml"));
       getChildren().add(node);
     } else if (tab.equals("Email")) {
       node =
           (Node)
               FXMLLoader.load(getClass().getResource("resource/email/view/email_viewpane.fxml"));
       getChildren().add(node);
     } else if (tab.equals("Apps")) {
       node =
           (Node) FXMLLoader.load(getClass().getResource("resource/apps/view/apps_viewpane.fxml"));
       getChildren().add(node);
     } else if (tab.equals("Bank")) {
       node =
           (Node)
               FXMLLoader.load(getClass().getResource("resource/bank/view/banks_viewpane.fxml"));
       getChildren().add(node);
     } else if (tab.equals("General")) {
       node = (Node) FXMLLoader.load(getClass().getResource("resource/general/contacts.fxml"));
       getChildren().add(node);
     }
   } catch (Exception e) {
     e.printStackTrace();
     node = null;
   }
 }
  public void showMarkovDialog(textgen.MarkovTextGenerator mtg) {
    try {
      // Load the fxml file and create a new stage for the popup
      FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/MarkovLayout.fxml"));
      BorderPane page = (BorderPane) loader.load();
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Markov Text Generator");
      // dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set reference to stage in controller
      // BUG -- when first displayed results don't show up until resize window
      MarkovController controller = loader.getController();
      // controller.setDialogStage(dialogStage);
      controller.setMainApp(this);
      controller.setMTG(mtg);

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();

    } catch (IOException e) {
      // Exception gets thrown if the fxml file could not be loaded
      e.printStackTrace();
    }
  }
示例#27
0
  public boolean showPersonEditDialog(Person person) {
    try {
      // Load the fxml file and create a new stage for the popup dialog.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(MainApp.class.getResource("view/PersonEditDialog.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Edit Person");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the person into the controller.
      PersonEditDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setPerson(person);

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();

      return controller.isOkClicked();
    } catch (IOException e) {
      e.printStackTrace();
      return false;
    }
  }
  // called at start of application
  @Override
  public void start(Stage primaryStage) {

    this.primaryStage = primaryStage;

    this.primaryStage.setTitle("TextProApp");

    try {
      // Load root layout from fxml
      FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/RootLayout.fxml"));
      rootLayout = (BorderPane) loader.load();
      Scene scene = new Scene(rootLayout);
      primaryStage.setScene(scene);

      // min height and width calculated from components in TextAppLayout
      primaryStage.setMinHeight(430);
      primaryStage.setMinWidth(334);
      primaryStage.show();

    } catch (Exception e) {
      e.printStackTrace();
    }

    showTextProApp();
  }
  /**
   * Displays dialog that allows user to select local text file to display in TextArea
   *
   * @param ta - reference to TextArea to display loaded text file
   */
  public void showLoadFileDialog(AutoSpellingTextArea ta) {
    try {
      // Load the fxml file and create a new stage for the popup
      FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/LoadFileLayout.fxml"));
      VBox page = (VBox) loader.load();
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Load File");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set reference to stage in controller
      LoadFileDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);

      // give controller reference to text area to load file into
      controller.setTextArea(ta);

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();

    } catch (IOException e) {
      // Exception gets thrown if the fxml file could not be loaded
      e.printStackTrace();
    }
  }
示例#30
0
  public Notification(Stage stage, int type, String message) {
    try {
      FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Notification.fxml"));
      fxmlLoader.setController(this);
      vbox = (VBox) fxmlLoader.load();
    } catch (IOException e) {
      e.printStackTrace();
    }

    if (type == INFO) {
      fxLabelTitle.setText("Information");
      fxImageViewLogo.setImage(
          new Image(vbox.getClass().getResource(IMAGE_DIRECTORY + "info.png").toExternalForm()));
    } else if (type == SUCCESS) {
      fxLabelTitle.setText("Success");
      fxImageViewLogo.setImage(
          new Image(vbox.getClass().getResource(IMAGE_DIRECTORY + "success.png").toExternalForm()));
    } else if (type == WARNING) {
      fxLabelTitle.setText("Warning");
      fxImageViewLogo.setImage(
          new Image(vbox.getClass().getResource(IMAGE_DIRECTORY + "warning.png").toExternalForm()));
    } else if (type == ERROR) {
      fxLabelTitle.setText("Error");
      fxImageViewLogo.setImage(
          new Image(vbox.getClass().getResource(IMAGE_DIRECTORY + "error.png").toExternalForm()));
    }

    if (!message.equals("")) {
      fxLabelMessage.setText(message);
    }

    show(stage);
  }