@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(); }); }
/** * Lance l'application * * @param primaryStage objet père qui contient la fenetre principale */ @Override public void start(Stage primaryStage) throws Exception { // Chargement de la fenetre principale FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource("fxml/VuePrincipale.fxml")); BorderPane root = fxmlLoader.load(); VuePrincipale vuePrincipaleControleur = (VuePrincipale) fxmlLoader.getController(); // Création du controleur de l'application Controleur controleurApplication = new Controleur(); // Passage du controleur de l'application au controleur de la vue vuePrincipaleControleur.setControleurApplication(controleurApplication); vuePrincipaleControleur.setVueGraphiqueControleurApplication(controleurApplication); vuePrincipaleControleur.initialiserObserveurs(); // Chargement de la vue des livraison FXMLLoader fxmlLoader2 = new FXMLLoader(getClass().getClassLoader().getResource("fxml/VueTextuelle.fxml")); AnchorPane anchorPane = fxmlLoader2.load(); VueTextuelle vueTextuelle = (VueTextuelle) fxmlLoader2.getController(); vueTextuelle.setAideurVueGraphique(vuePrincipaleControleur.getAideurVueGraphique()); vueTextuelle.setControleurApplication(controleurApplication); vueTextuelle.initialiserObserveurs(); BorderPane centerBorderPane = (BorderPane) root.getCenter(); centerBorderPane.setLeft(anchorPane.getChildren().get(0)); primaryStage.setTitle("Optimod'Lyon"); primaryStage.setScene(new Scene(root, LARGEUR_FENETRE, HAUTEUR_FENETRE)); primaryStage.setMinWidth(LARGEUR_FENETRE); primaryStage.setMinHeight(HAUTEUR_FENETRE); primaryStage.widthProperty().addListener(vuePrincipaleControleur.ecouteurDeRedimensionnement); primaryStage.heightProperty().addListener(vuePrincipaleControleur.ecouteurDeRedimensionnement); primaryStage.show(); }
@Override public void start(Stage primaryStage) throws Exception { BorderPane pane = FXMLLoader.load(FXMLSample.class.getResource("sample.fxml")); BorderPane browserPane = (BorderPane) pane.getCenter(); final Browser browser = new Browser(); browserPane.setCenter(new BrowserView(browser)); final TextField textField = (TextField) pane.getTop(); textField.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { browser.loadURL(textField.getText()); } }); primaryStage.setTitle("FXMLSample"); primaryStage.setScene(new Scene(pane, 800, 600)); primaryStage.show(); browser.loadURL(textField.getText()); }
@Override public void start(Stage primaryStage) { FXFormPane formPane = new FXFormPane(); formPane.addChild( createLabel("First 0, 0 / Butter", "fce94f"), formPane.createConstraint(0, 0)); formPane.addChild( createLabel("Second 1, 0 / Orange", "fcaf3e"), formPane.createConstraint(1, 0)); formPane.addChild( createLabel("Third 2, 0 / Chocolate", "e9b96e"), formPane.createConstraint(2, 0)); formPane.addChild( createLabel("Fourth 3, 0 / Butter", "fce94f"), formPane.createConstraint(3, 0)); formPane.addChild( createLabel("Right aligned -1, 0 / Chameleon", "8ae234"), formPane.createConstraint(-1, 0)); formPane.addChild( createLabel("Next line 0, 1 / Sky Blue", "729fcf"), formPane.createConstraint(0, 1)); formPane.addChild( createLabel("Right aligned -1, 1 / Plum", "ad7fa8"), formPane.createConstraint(-1, 1)); formPane.addChild( createLabel("Next line 0, 2 / Sky Blue", "729fcf"), formPane.createConstraint(0, 2)); formPane.addChild( createLabel("Right aligned -1, 2 / Plum", "ad7fa8"), formPane.createConstraint(-1, 2)); formPane.addChild( createLabel("Centered 0, 3, -1, -4 / Aluminium", "eeeeec"), formPane.createConstraint(0, 3, -1, -4)); formPane.addChild( createLabel("Bottom 0, -3 / Scarlet Red", "ef2929"), formPane.createConstraint(0, -3)); formPane.addChild( createLabel("Bottom and Right aligned -1, -3 / Butter", "c4a000"), formPane.createConstraint(-1, -3)); formPane.addChild( createLabel("Bottom 0, -2 / Scarlet Red", "ef2929"), formPane.createConstraint(0, -2)); formPane.addChild( createLabel("Bottom and Right aligned -1, -2 / Butter", "c4a000"), formPane.createConstraint(-1, -2)); formPane.addChild( createLabel("Bottom 0, -1 / Scarlet Red", "ef2929"), formPane.createConstraint(0, -1)); formPane.addChild( createLabel("Bottom and Right aligned -1, -1 / Butter", "c4a000"), formPane.createConstraint(-1, -1)); Slider hgapSlider = new Slider(0, 100, formPane.getHGap()); formPane.hGapProperty().bind(hgapSlider.valueProperty()); Slider vgapSlider = new Slider(0, 100, formPane.getVGap()); formPane.vGapProperty().bind(vgapSlider.valueProperty()); FXFormPane controlPane = new FXFormPane(); controlPane.setNewlineCount(7); controlPane.addChild(hgapSlider); controlPane.addChild(vgapSlider); BorderPane root = new BorderPane(); root.setBottom(createLabel("- - Bottom - -", "888a85")); root.setCenter(formPane); root.setLeft(createLabel(" | \n\n | \n\n Left \n\n | \n\n | \n\n", "babdb6")); root.setRight(createLabel(" | \n\n | \n\n Right \n\n | \n\n | \n\n", "555753")); root.setTop(controlPane); BorderPane.setAlignment(root.getBottom(), Pos.CENTER); BorderPane.setAlignment(root.getCenter(), Pos.CENTER); BorderPane.setAlignment(root.getLeft(), Pos.CENTER); BorderPane.setAlignment(root.getRight(), Pos.CENTER); BorderPane.setAlignment(root.getTop(), Pos.CENTER); primaryStage.setScene(new Scene(root)); primaryStage.setTitle("JavaFX FormPane Test"); primaryStage.show(); }