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; } }
@Override public void start(Stage stage) throws Exception { primaryStage = stage; primaryStage.setTitle("Générateur de trames de surveillances"); FXMLLoader loader = new FXMLLoader(); loader.setLocation(Main.class.getResource("../../../zoo/generator/view/RootLayout.fxml")); try { rootLayout = loader.load(); Scene scene = new Scene(rootLayout); primaryStage.setScene(scene); // Main panel FXMLLoader loader2 = new FXMLLoader(); loader2.setLocation(Main.class.getResource("../../../zoo/generator/view/MainPanel.fxml")); BorderPane o = loader2.load(); scene.setRoot(o); MainPanelController controller = loader2.getController(); controller.setRandomGenerationService(RandomGenerationService.getInstance()); primaryStage.show(); primaryStage.setOnCloseRequest( new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { System.out.println("Arrêt des threads"); Thread[] threads = new Thread[100]; int n = Thread.enumerate(threads); for (int i = 0; i < n; i++) { System.out.println(threads[i]); } // 1. Stop random generation RandomGenerationService.getInstance().stop(); // 2. Stop server thread Server.getInstance().stop(); // 3. Stop client threads ClientHandler.stopAll(); System.out.println("Après l'arrêt des threads"); } }); Server.getInstance().start(); } catch (IOException e) { e.printStackTrace(); } }
@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(); } }
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; } }
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(); } }
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(); } }
@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); } }
/** 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 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; } }
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 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; } }
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(); } }
@FXML private void HandleFindReplaceDialog() { FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("fxml/FindReplaceDialog.fxml")); try { AnchorPane optionsDialog = loader.load(); Stage dialogStage = new Stage(); dialogStage.setTitle("Rechecher / Remplacer"); Scene scene = new Scene(optionsDialog); dialogStage.setScene(scene); dialogStage .getIcons() .add(new Image(MainApp.class.getResourceAsStream("assets/static/icons/logo.png"))); dialogStage.setResizable(false); dialogStage.initModality(Modality.APPLICATION_MODAL); FindReplaceDialog findReplaceDialog = loader.getController(); findReplaceDialog.setMainApp(mainApp); findReplaceDialog.setWindow(dialogStage); findReplaceDialog.setMdConvertController(this); dialogStage.show(); } catch (IOException e) { logger.error(e.getMessage(), e); } }
private void showContentView(String fileName) { try { FXMLLoader loader = new FXMLLoader(); loader.setLocation(Main.class.getResource("views/" + fileName)); AnchorPane contentView = (AnchorPane) loader.load(); content.setCenter(contentView); } catch (IOException e) { e.printStackTrace(); } }
@FXML private void HandleTableButtonAction(ActionEvent event) throws IOException { // Create the custom dialog. Dialog<Pair<ObservableList, ObservableList<ZRow>>> dialog = new Dialog<>(); dialog.setTitle("Editeur de tableau"); dialog.setHeaderText(""); // Set the icon (must be included in the project). dialog.setGraphic( new ImageView(MainApp.class.getResource("assets/static/icons/table.png").toString())); // Set the button types. dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("fxml/TableEditor.fxml")); BorderPane tableEditor = loader.load(); TableView<ZRow> tbView = (TableView) tableEditor.getCenter(); TableController controller = loader.getController(); controller.setEditor(this); dialog.getDialogPane().setContent(tableEditor); dialog.setResultConverter( dialogButton -> { if (dialogButton == ButtonType.OK) { return new Pair<>(tbView.getColumns(), tbView.getItems()); } return null; }); Optional<Pair<ObservableList, ObservableList<ZRow>>> result = dialog.showAndWait(); result.ifPresent( datas -> { String[][] data = new String[datas.getValue().size()][datas.getValue().get(0).getRow().size()]; String[] headers = new String[datas.getKey().size()]; int cpt = 0; for (Object key : datas.getKey()) { headers[cpt] = ((TextField) ((TableColumn) key).getGraphic()).getText(); cpt++; } for (int i = 0; i < datas.getValue().size(); i++) { for (int j = 0; j < datas.getValue().get(i).getRow().size(); j++) { data[i][j] = datas.getValue().get(i).getRow().get(j); } } String tablestring = FlipTable.of(headers, data); SourceText.replaceText(SourceText.getSelection(), "\n\n" + tablestring + "\n\n"); SourceText.requestFocus(); }); }
@Override public Pane initialize(Presenter presenter, ModuleManager moduleManager) throws IOException { FXMLLoader loader = new FXMLLoader(); loader.setLocation(getClass().getResource("/employees/fxml/EmployeeTab.fxml")); loader.setController(new EmployeeTabController(presenter, moduleManager)); // add hibernate shutdown listener presenter.addOnStopListener(HibernateUtils::shutdown); return loader.load(); }
private static ManageStaffController launch() throws IOException { FXMLLoader fxmlLoader = new FXMLLoader(); fxmlLoader.setLocation(ManageStaffController.class.getResource("manageStaff.fxml")); Pane selfPane = fxmlLoader.load(); ManageStaffController controller = fxmlLoader.getController(); controller.informController = InformController.newInformController(selfPane); controller.selfPane = controller.informController.stackPane; return controller; }
private void initLoader() { try { fxmlLoader.setLocation(getClass().getResource("editSites.fxml")); fxmlEdit = fxmlLoader.load(); editDialogSites = fxmlLoader.getController(); } catch (IOException e) { e.printStackTrace(); } }
public void initRootLayout() { try { FXMLLoader loader = new FXMLLoader(); loader.setLocation(ChessFx.class.getResource("view/javafx/ChessFx.fxml")); rootLayout = loader.load(); Scene scene = new Scene(rootLayout); primaryStage.setScene(scene); primaryStage.show(); } catch (IOException e) { e.printStackTrace(); } }
public ConsolePanel(int id) { this.id = id; FXMLLoader loader = new FXMLLoader(getClass().getResource("controlStation/console/console_panel.fxml")); loader.setLocation(ClassLoader.getSystemResource("controlStation/console/console_panel.fxml")); controller = new ConsolePanelController(); loader.setController(controller); try { root = loader.load(); } catch (IOException e) { e.printStackTrace(); } }
@Override public void start(Stage stage) throws MalformedURLException, IOException { URL fxmlUrl = this.getClass().getClassLoader().getResource("test1/main.fxml"); FXMLLoader loader = new FXMLLoader(); loader.setLocation(fxmlUrl); VBox root = loader.<VBox>load(); Scene scene = new Scene(root); stage.setScene(scene); stage.setTitle("Nesting Documents in FXML"); stage.show(); }
public Parent load(String name) { URL location = FxmlLoader.class.getResource(name); fxmlLoader = new FXMLLoader(); fxmlLoader.setLocation(location); fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory()); try { return (Parent) fxmlLoader.load(location.openStream()); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void start(Stage primaryStage) { try { FXMLLoader loader = new FXMLLoader(); loader.setLocation(Main.class.getResource("Gui.fxml")); Pane root = (Pane) loader.load(); Scene scene = new Scene(root); scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); } catch (Exception e) { e.printStackTrace(); } }
private void showWindowEuler() { FXMLLoader loader = new FXMLLoader(); loader.setLocation(MjjMain.class.getResource("javafx/view/WindowEuler.fxml")); try { AnchorPane windowEuler = (AnchorPane) loader.load(); Scene scene = new Scene(windowEuler); rootLayout.setCenter(windowEuler); } catch (IOException e) { e.printStackTrace(); } }
/** * Load a FXML component. * * <p>The fxml path could be : * * <ul> * <li>Relative : fxml file will be loaded with the classloader of the given model class * <li>Absolute : fxml file will be loaded with default thread class loader, packages must be * separated by / character * </ul> * * @param model the model that will manage the fxml node * @param fxmlPath the fxml string path * @param bundlePath the bundle string path * @return a FXMLComponent object that wrap a fxml node with its controller * @param <M> the model type that will manage this fxml node */ @SuppressWarnings("unchecked") public static <M extends Model> FXMLComponentBase loadFXML( final M model, final String fxmlPath, final String bundlePath) { final FXMLLoader fxmlLoader = new FXMLLoader(); // Use Custom controller factory to attach the root model to the controller fxmlLoader.setControllerFactory(new DefaultFXMLControllerBuilder(model)); fxmlLoader.setLocation(convertFxmlUrl(model, fxmlPath)); try { if (bundlePath != null) { fxmlLoader.setResources(ResourceBundle.getBundle(bundlePath)); } } catch (final MissingResourceException e) { LOGGER.log(MISSING_RESOURCE_BUNDLE, e, bundlePath); } Node node = null; boolean error = false; try { error = fxmlLoader.getLocation() == null; if (error) { node = TextBuilder.create().text(FXML_ERROR_NODE_LABEL.getText(fxmlPath)).build(); } else { node = (Node) fxmlLoader.load(fxmlLoader.getLocation().openStream()); } } catch (final IOException e) { throw new CoreRuntimeException(FXML_NODE_DOESNT_EXIST.getText(fxmlPath), e); } final FXMLController<M, ?> fxmlController = (FXMLController<M, ?>) fxmlLoader.getController(); // It's tolerated to have a null controller for an fxml node if (fxmlController != null) { // The fxml controller must extends AbstractFXMLController if (!error && !(fxmlLoader.getController() instanceof AbstractFXMLController)) { throw new CoreRuntimeException( BAD_FXML_CONTROLLER_ANCESTOR.getText( fxmlLoader.getController().getClass().getCanonicalName())); } // Link the View component with the fxml controller fxmlController.setModel(model); } return new FXMLComponentBase(node, fxmlController); }
/** Initializes the root layout. */ public void initRootLayout() { try { // Load root layout from fxml file. FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("view/RootLayout.fxml")); rootLayout = (BorderPane) loader.load(); // Show the scene containing the root layout. Scene scene = new Scene(rootLayout); primaryStage.setScene(scene); primaryStage.show(); } catch (IOException e) { e.printStackTrace(); } }
private void createScene() { try { URL location = getClass().getResource("stackedareachart.fxml"); FXMLLoader fxmlLoader = new FXMLLoader(); fxmlLoader.setLocation(location); fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory()); Parent root = (Parent) fxmlLoader.load(location.openStream()); chartFxPanel.setScene(new Scene(root)); controller = (StackedAreaChartController) fxmlLoader.getController(); } catch (IOException ex) { Exceptions.printStackTrace(ex); } }
private void initRootLayout() { FXMLLoader loader = new FXMLLoader(); loader.setLocation(MjjMain.class.getResource("MjjMain.fxml")); try { rootLayout = (BorderPane) loader.load(); Scene scene = new Scene(rootLayout); primryStage.setScene(scene); primryStage.show(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void initRootLayout() { System.out.println("Initializing root layout"); try { FXMLLoader loader = new FXMLLoader(); loader.setLocation(TRLauncher.class.getResource("view/RootLayout.fxml")); rootLayout = loader.load(); Scene scene = new Scene(rootLayout); primaryStage.setScene(scene); primaryStage.show(); } catch (IOException e) { System.err.println("Couldn't find the specified layout"); e.printStackTrace(); } }