Java Code Examples for javafx.scene.layout.GridPane#setVgap()
The following examples show how to use
javafx.scene.layout.GridPane#setVgap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Demo.java From Enzo with Apache License 2.0 | 6 votes |
@Override public void start(Stage stage) { GridPane pane = new GridPane(); pane.setHgap(10); pane.setVgap(10); pane.add(german, 0, 0); pane.add(english, 1, 0); pane.add(french, 2, 0); pane.add(spanish, 0, 1); pane.add(dutch, 1, 1); pane.add(german1, 2, 1); Scene scene = new Scene(pane, Color.DARKGRAY); stage.setTitle("JavaFX QlockTwo"); stage.setScene(scene); stage.show(); }
Example 2
Source File: OnlyTrayIconDemo.java From oim-fx with MIT License | 6 votes |
@Override public void start(final Stage stage) throws Exception { enableTray(stage); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(20); grid.setVgap(20); grid.setGridLinesVisible(true); grid.setPadding(new Insets(25, 25, 25, 25)); Button b1 = new Button("测试1"); Button b2 = new Button("测试2"); grid.add(b1, 0, 0); grid.add(b2, 1, 1); Scene scene = new Scene(grid, 800, 600); stage.setScene(scene); stage.show(); Platform.setImplicitExit(false); }
Example 3
Source File: ToggleButtonSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public ToggleButtonSample() { // create label to show result of selected toggle button final Label label = new Label(); label.setStyle("-fx-font-size: 2em;"); // create 3 toggle buttons and a toogle group for them final ToggleButton tb1 = new ToggleButton("Cat"); final ToggleButton tb2 = new ToggleButton("Dog"); final ToggleButton tb3 = new ToggleButton("Horse"); ToggleGroup group = new ToggleGroup(); tb1.setToggleGroup(group); tb2.setToggleGroup(group); tb3.setToggleGroup(group); group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle selectedToggle) { if(selectedToggle!=null) { label.setText(((ToggleButton) selectedToggle).getText()); } else { label.setText("..."); } } }); // select the first button to start with group.selectToggle(tb1); // add buttons and label to grid and set their positions GridPane.setConstraints(tb1,0,0); GridPane.setConstraints(tb2,1,0); GridPane.setConstraints(tb3,2,0); GridPane.setConstraints(label,0,1,3,1); GridPane grid = new GridPane(); grid.setVgap(20); grid.setHgap(10); getChildren().add(grid); grid.getChildren().addAll(tb1, tb2, tb3, label); }
Example 4
Source File: Exercise_15_05.java From Intro-to-Java-Programming with MIT License | 5 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create UI GridPane pane = new GridPane(); pane.setVgap(5); pane.setHgap(5); pane.add(new Label("Investment Amount:"), 0, 0); pane.add(tfInvestmentAmount, 1, 0); pane.add(new Label("Number Of Years:"), 0, 1); pane.add(tfNumberOfYears, 1, 1); pane.add(new Label("Annual Interest Rate:"), 0, 2); pane.add(tfAnnualInterestRate, 1, 2); pane.add(new Label("Future value:"), 0, 3); pane.add(tfFutureValue, 1, 3); pane.add(btCalculate, 1, 4); // Set UI properties pane.setAlignment(Pos.CENTER); tfInvestmentAmount.setAlignment(Pos.BOTTOM_RIGHT); tfNumberOfYears.setAlignment(Pos.BOTTOM_RIGHT); tfAnnualInterestRate.setAlignment(Pos.BOTTOM_RIGHT); tfFutureValue.setAlignment(Pos.BOTTOM_RIGHT); tfFutureValue.setEditable(false); pane.setHalignment(btCalculate, HPos.RIGHT); pane.setPadding(new Insets(10, 10, 10, 10)); // Process events btCalculate.setOnAction(e -> futureValue()); // Create a scene and place it in the stage Scene scene = new Scene(pane); primaryStage.setTitle("Exercise_15_05"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 5
Source File: Main.java From mars-sim with GNU General Public License v3.0 | 5 votes |
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Borders"); //primaryStage.initStyle(StageStyle.UTILITY); // .UNDECORATED);// Group root = new Group(); Scene scene = new Scene(root, 600, 330, Color.WHITE); //TRANSPARENT);// scene.setFill(Color.TRANSPARENT); scene.getStylesheets().add(this.getClass().getResource("/fxui/css/demo/main.css").toExternalForm()); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10); gridpane.setVgap(10); final String cssDefault = "-fx-border-color: blue;\n" + "-fx-border-insets: 5;\n" + "-fx-border-width: 3;\n" + "-fx-border-style: dashed;\n"; final HBox pictureRegion = new HBox(); pictureRegion.setStyle(cssDefault); gridpane.add(pictureRegion, 1, 1,10,10); root.getChildren().add(gridpane); primaryStage.setScene(scene); primaryStage.show(); }
Example 6
Source File: RregulloPunen.java From Automekanik with GNU General Public License v3.0 | 5 votes |
public RregulloPunen(int id, boolean kryer, TeDhenat td){ stage.initModality(Modality.APPLICATION_MODAL); stage.setResizable(false); stage.setTitle("Rregullo"); HBox btn = new HBox(5); btn.getChildren().addAll(btnOk, btnAnulo); btn.setAlignment(Pos.CENTER_RIGHT); GridPane grid = new GridPane(); grid.add(cbKryer, 0, 0); grid.add(btn, 0, 1); grid.setVgap(10); grid.setAlignment(Pos.CENTER); cbKryer.setSelected(kryer); btnOk.setOnAction(e -> { azhurno(id); new Thread(new Runnable() { @Override public void run() { td.mbush(); } }).start(); }); btnAnulo.setOnAction(e -> stage.close()); Scene scene = new Scene(grid, 230, 100); scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm()); stage.setScene(scene); stage.show(); }
Example 7
Source File: Exercise_16_08.java From Intro-to-Java-Programming with MIT License | 5 votes |
/** Return a grid pane of circle info */ protected GridPane getGrid( TextField centerX, TextField centerY, TextField r) { GridPane gridPane = new GridPane(); gridPane.setHgap(5); gridPane.setVgap(2); gridPane.add(new Label("Center x:"), 0, 0); gridPane.add(centerX, 1, 0); gridPane.add(new Label("Center y:"), 0, 1); gridPane.add(centerY, 1, 1); gridPane.add(new Label("Radius:"), 0, 2); gridPane.add(r, 1, 2); return gridPane; }
Example 8
Source File: NumberSpinnerDemo.java From mars-sim with GNU General Public License v3.0 | 5 votes |
@Override public void start(Stage primaryStage) { primaryStage.setTitle("JavaFX Spinner Demo"); GridPane root = new GridPane(); root.setHgap(10); root.setVgap(10); root.setPadding(new Insets(10, 10, 10, 10)); final NumberSpinner defaultSpinner = new NumberSpinner(); final NumberSpinner decimalFormat = new NumberSpinner(BigDecimal.ZERO, new BigDecimal("0.05"), new DecimalFormat("#,##0.00")); final NumberSpinner percent = new NumberSpinner(BigDecimal.ZERO, new BigDecimal("0.01"), NumberFormat.getPercentInstance()); final NumberSpinner localizedCurrency = new NumberSpinner(BigDecimal.ZERO, new BigDecimal("0.01"), NumberFormat.getCurrencyInstance(Locale.UK)); root.addRow(1, new Label("default"), defaultSpinner); root.addRow(2, new Label("custom decimal format"), decimalFormat); root.addRow(3, new Label("percent"), percent); root.addRow(4, new Label("localized currency"), localizedCurrency); Button button = new Button("Dump layout bounds"); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { defaultSpinner.dumpSizes(); } }); root.addRow(5, new Label(), button); Scene scene = new Scene(root); //String path = NumberSpinnerDemo.class.getResource("/fxui/css/spinner/number_spinner.css").toExternalForm(); String path = "/fxui/css/spinner/number_spinner.css"; System.out.println("path = " + path); //scene.getStylesheets().add(path); scene.getStylesheets().add(getClass().getResource(path).toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); }
Example 9
Source File: TakeOfferView.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private void addGridPane() { gridPane = new GridPane(); gridPane.getStyleClass().add("content-pane"); gridPane.setPadding(new Insets(15, 15, -1, 15)); gridPane.setHgap(5); gridPane.setVgap(5); ColumnConstraints columnConstraints1 = new ColumnConstraints(); columnConstraints1.setHalignment(HPos.RIGHT); columnConstraints1.setHgrow(Priority.NEVER); columnConstraints1.setMinWidth(200); ColumnConstraints columnConstraints2 = new ColumnConstraints(); columnConstraints2.setHgrow(Priority.ALWAYS); gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2); scrollPane.setContent(gridPane); }
Example 10
Source File: Properties.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private void setCommand(final TreeItem<ScanCommand> tree_item) { final GridPane prop_grid = new GridPane(); prop_grid.setPadding(new Insets(5)); prop_grid.setHgap(5); prop_grid.setVgap(5); if (tree_item != null) { int row = 0; for (ScanCommandProperty prop : tree_item.getValue().getProperties()) { final Label label = new Label(prop.getName()); prop_grid.add(label, 0, row); try { final Node editor = createEditor(tree_item, prop); GridPane.setHgrow(editor, Priority.ALWAYS); GridPane.setFillWidth(editor, true); // Label defaults to vertical center, // which is good for one-line editors. if (editor instanceof StringArrayEditor) GridPane.setValignment(label, VPos.TOP); prop_grid.add(editor, 1, row++); } catch (Exception ex) { logger.log(Level.WARNING, "Cannot create editor for " + prop, ex); } ++row; } } scroll.setContent(prop_grid); }
Example 11
Source File: ShtoPunetor.java From Automekanik with GNU General Public License v3.0 | 4 votes |
public ShtoPunetor(){ stage.getIcons().add(new Image(getClass().getResourceAsStream("/sample/foto/icon.png"))); stage.setTitle("Shtimi i punetoreve"); stage.initModality(Modality.APPLICATION_MODAL); stage.setResizable(false); HBox btn = new HBox(5); btn.setAlignment(Pos.CENTER_RIGHT); btn.getChildren().addAll(btnOk, btnAnulo); data.setValue(LocalDate.now()); GridPane root = new GridPane(); root.add(new Label("Emri"), 0, 0); root.add(emri, 1, 0); root.add(new Label("Mbiemri"), 0, 1); root.add(mbiemri, 1, 1); root.add(new Label("Fjalekalimi"), 0, 2); root.add(pw, 1, 2); root.add(new Label("Komuna"), 0, 3); root.add(komuna, 1, 3); root.add(new Label("Pozita"), 0, 4); root.add(pjesa, 1, 4); root.add(new Label("Paga mujore"), 0, 5); root.add(paga, 1, 5); root.add(new Label("Data e regjistrimit"), 0, 6); root.add(data, 1, 6); root.add(btn, 1, 7); btnOk.setOnAction(e -> { shtoPunetoreMethod(); }); btnAnulo.setOnAction(e -> stage.close()); data.setOnKeyPressed(e -> { if (e.getCode().equals(KeyCode.ENTER)) shtoPunetoreMethod(); else if (e.getCode().equals(KeyCode.ESCAPE)) stage.close(); }); emri.setOnKeyPressed(e -> { if (e.getCode().equals(KeyCode.ENTER)) shtoPunetoreMethod(); else if (e.getCode().equals(KeyCode.ESCAPE)) stage.close(); }); mbiemri.setOnKeyPressed(e -> { if (e.getCode().equals(KeyCode.ENTER)) shtoPunetoreMethod(); else if (e.getCode().equals(KeyCode.ESCAPE)) stage.close(); }); komuna.setOnKeyPressed(e -> { if (e.getCode().equals(KeyCode.ENTER)){shtoPunetoreMethod(); }}); pjesa.setOnKeyPressed(e -> { if (e.getCode().equals(KeyCode.ENTER)) shtoPunetoreMethod(); else if (e.getCode().equals(KeyCode.ESCAPE)) stage.close(); }); paga.setOnKeyPressed(e -> { if (e.getCode().equals(KeyCode.ENTER)) shtoPunetoreMethod(); else if (e.getCode().equals(KeyCode.ESCAPE)) stage.close(); }); root.setVgap(7); root.setHgap(5); root.setAlignment(Pos.CENTER); Scene scene = new Scene(root, 360, 370); scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm()); stage.setScene(scene); stage.show(); }
Example 12
Source File: IconEditorFactory.java From constellation with Apache License 2.0 | 4 votes |
@Override protected Node createEditorControls() { final GridPane controls = new GridPane(); controls.setAlignment(Pos.CENTER); controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING); final ColumnConstraints cc = new ColumnConstraints(); cc.setHgrow(Priority.ALWAYS); controls.getColumnConstraints().add(cc); final RowConstraints rc = new RowConstraints(); rc.setVgrow(Priority.ALWAYS); controls.getRowConstraints().add(rc); // build tree structure of icon final IconNode builtInNode = new IconNode("(Built-in)", IconManager.getIconNames(false)); //convert structure to jfx treeview builtInItem = new TreeItem<>(builtInNode); addNode(builtInItem, builtInNode); // set listview factory to display icon listView = new ListView<>(); listView.setCellFactory(param -> new IconNodeCell()); listView.getStyleClass().add("rounded"); listView.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { update(); }); treeRoot = new TreeItem<>(new IconNode("Icons", new HashSet<>())); treeRoot.setExpanded(true); treeView = new TreeView<>(); treeView.setShowRoot(true); treeView.setRoot(treeRoot); treeView.getStyleClass().add("rounded"); treeView.setOnMouseClicked((MouseEvent event) -> { refreshIconList(); }); final SplitPane splitPane = new SplitPane(); splitPane.setId("hiddenSplitter"); splitPane.setOrientation(Orientation.HORIZONTAL); splitPane.getItems().add(treeView); splitPane.getItems().add(listView); controls.addRow(0, splitPane); final HBox addRemoveBox = createAddRemoveBox(); controls.addRow(1, addRemoveBox); return controls; }
Example 13
Source File: DatePickerSample.java From marathonv5 with Apache License 2.0 | 4 votes |
private void initUI() { VBox vbox = new VBox(20); vbox.setStyle("-fx-padding: 10;"); Scene scene = new Scene(vbox, 400, 400); stage.setScene(scene); checkInDatePicker = new DatePicker(); checkOutDatePicker = new DatePicker(); checkInDatePicker.setValue(LocalDate.now()); final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker datePicker) { return new DateCell() { @Override public void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); if (item.isBefore(checkInDatePicker.getValue().plusDays(1))) { setDisable(true); setStyle("-fx-background-color: #ffc0cb;"); } long p = ChronoUnit.DAYS.between(checkInDatePicker.getValue(), item); setTooltip(new Tooltip("You're about to stay for " + p + " days")); } }; } }; checkOutDatePicker.setDayCellFactory(dayCellFactory); checkOutDatePicker.setValue(checkInDatePicker.getValue().plusDays(1)); checkInDatePicker.setChronology(ThaiBuddhistChronology.INSTANCE); checkOutDatePicker.setChronology(HijrahChronology.INSTANCE); GridPane gridPane = new GridPane(); gridPane.setHgap(10); gridPane.setVgap(10); Label checkInlabel = new Label("Check-In Date:"); gridPane.add(checkInlabel, 0, 0); GridPane.setHalignment(checkInlabel, HPos.LEFT); gridPane.add(checkInDatePicker, 0, 1); Label checkOutlabel = new Label("Check-Out Date:"); gridPane.add(checkOutlabel, 0, 2); GridPane.setHalignment(checkOutlabel, HPos.LEFT); gridPane.add(checkOutDatePicker, 0, 3); vbox.getChildren().add(gridPane); }
Example 14
Source File: EditMultipleItemsAction.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private Node createContent(final Model model) { final GridPane grid = new GridPane(); grid.setHgap(5.0); grid.setVgap(5.0); int row = 0; grid.add(new Label("Apply"), 0, row++); visible.setSelected(true); grid.add(set_visible, 0, row); grid.add(visible, 1, row++); visible.setOnAction(event -> set_visible.setSelected(true)); grid.add(set_color, 0, row); grid.add(color, 1, row++); color.setOnAction(event -> set_color.setSelected(true)); GridPane.setHgrow(period, Priority.ALWAYS); grid.add(set_period, 0, row); grid.add(period, 1, row++); period.setOnKeyPressed(event -> set_period.setSelected(true)); grid.add(set_buffer, 0, row); grid.add(buffer, 1, row++); buffer.setOnKeyPressed(event -> set_buffer.setSelected(true)); axis.setMaxWidth(Double.MAX_VALUE); axis.getItems().setAll(model.getAxes() .stream() .map(AxisConfig::getResolvedName) .collect(Collectors.toList())); grid.add(set_axis, 0, row); grid.add(axis, 1, row++); axis.setOnAction(event -> set_axis.setSelected(true)); type.setMaxWidth(Double.MAX_VALUE); type.getItems().setAll(TraceType.getDisplayNames()); type.getSelectionModel().select(TraceType.AREA.ordinal()); grid.add(set_type, 0, row); grid.add(type, 1, row++); type.setOnAction(event -> set_type.setSelected(true)); grid.add(set_width, 0, row); grid.add(width, 1, row++); width.setOnKeyPressed(event -> set_width.setSelected(true)); style.setMaxWidth(Double.MAX_VALUE); style.getItems().setAll(LineStyle.getDisplayNames()); style.getSelectionModel().select(LineStyle.SOLID.ordinal()); grid.add(set_style, 0, row); grid.add(style, 1, row++); style.setOnAction(event -> set_style.setSelected(true)); point.setMaxWidth(Double.MAX_VALUE); point.getItems().setAll(PointType.getDisplayNames()); point.getSelectionModel().select(PointType.NONE.ordinal()); grid.add(set_point, 0, row); grid.add(point, 1, row++); point.setOnAction(event -> set_point.setSelected(true)); grid.add(set_size, 0, row); grid.add(size, 1, row++); size.setOnKeyPressed(event -> set_size.setSelected(true)); optimized.setSelected(true); grid.add(set_optimized, 0, row); grid.add(optimized, 1, row++); optimized.setOnAction(event -> set_optimized.setSelected(true)); return grid; }
Example 15
Source File: ShtoPunetor.java From Automekanik with GNU General Public License v3.0 | 4 votes |
public ShtoPunetor(DritarjaKryesore dk, String dump){ stage.getIcons().add(new Image(getClass().getResourceAsStream("/sample/foto/icon.png"))); stage.setTitle("Ndrysho fjalekalimin"); stage.initModality(Modality.APPLICATION_MODAL); stage.setResizable(false); HBox btn = new HBox(5); btn.setAlignment(Pos.CENTER_RIGHT); btn.getChildren().addAll(btnOk, btnAnulo); data.setValue(LocalDate.now()); GridPane root = new GridPane(); root.add(new Label("Emri"), 0, 0); root.add(user, 1, 0); root.add(new Label("Fjalekalimi"), 0, 1); root.add(pw, 1, 1); root.add(shfaq, 2, 1); root.add(lblPw, 1, 2); root.add(btn, 1, 4); shfaq.setGraphic(new ImageView(new Image("/sample/foto/eye.png"))); shfaq.setOnMousePressed(e -> lblPw.setText(pw.getText())); shfaq.setOnMouseReleased(e -> lblPw.setText("")); user.setText(dk.log_user.getText()); pw.setText(dk.log_pw.getText()); user.setEditable(false); user.setTooltip(new Tooltip("Emri nuk mund te ndryshohet")); btnOk.setOnAction(e -> { if (pw.getText().length() > 5){ rregullo(Integer.parseInt(dk.lblId.getText())); }else new Mesazhi("Info", "Fjalekalimi i shkurte", "Fjalekalimi duhet te jete mbi 5 karaktere i gjate."); }); btnAnulo.setOnAction(e -> stage.close()); pw.setOnKeyPressed(e -> {if (e.getCode().equals(KeyCode.ENTER)){ if (pw.getText().length() > 5) rregullo(Integer.parseInt(dk.lblId.getText())); else new Mesazhi("Info", "Fjalekalimi i shkurte", "Fjalekalimi duhet te jete mbi 5 karaktere i gjate."); }}); emri.setOnKeyPressed(e -> {if (e.getCode().equals(KeyCode.ENTER)){ if (pw.getText().length() > 5) rregullo(Integer.parseInt(dk.lblId.getText())); else new Mesazhi("Info", "Fjalekalimi i shkurte", "Fjalekalimi duhet te jete mbi 5 karaktere i gjate."); }}); root.setVgap(7); root.setHgap(5); root.setAlignment(Pos.CENTER); Scene scene = new Scene(root, 320, 210); scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm()); stage.setScene(scene); stage.show(); }
Example 16
Source File: LoginApplication.java From marathonv5 with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 300, 150); stage.setScene(scene); stage.setTitle("Text Field Sample"); GridPane grid = new GridPane(); grid.setPadding(new Insets(10, 10, 10, 10)); grid.setVgap(5); grid.setHgap(5); scene.setRoot(grid); final TextField name = new TextField(); name.setPromptText("User Name:"); HBox.setHgrow(name, Priority.ALWAYS); GridPane.setConstraints(name, 0, 0); grid.getChildren().add(name); final TextField lastName = new TextField(); lastName.setPromptText("Password:"); HBox.setHgrow(lastName, Priority.ALWAYS); GridPane.setConstraints(lastName, 0, 1); grid.getChildren().add(lastName); Button submit = new Button("Submit"); GridPane.setConstraints(submit, 0, 2); grid.getChildren().add(submit); submit.setOnAction((ActionEvent e) -> { ProcessBuilder pb = new ProcessBuilder("java", "-cp", System.getProperty("java.class.path"), ButtonSample.class.getName()); try { if (System.getenv("USER_JTO") != null) { pb.environment().put("JAVA_TOOL_OPTIONS", System.getenv("USER_JTO")); } Process process = pb.start(); System.exit(0); } catch (IOException e1) { e1.printStackTrace(); } }); stage.show(); }
Example 17
Source File: GitFxDialog.java From GitFx with Apache License 2.0 | 4 votes |
@Override public String gitOpenDialog(String title, String header, String content) { String repo; DirectoryChooser chooser = new DirectoryChooser(); Dialog<Pair<String, GitFxDialogResponse>> dialog = new Dialog<>(); //Dialog<Pair<String, GitFxDialogResponse>> dialog = getCostumeDialog(); dialog.setTitle(title); dialog.setHeaderText(header); dialog.setContentText(content); ButtonType okButton = new ButtonType("Ok"); ButtonType cancelButton = new ButtonType("Cancel"); dialog.getDialogPane().getButtonTypes().addAll(okButton, cancelButton); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField repository = new TextField(); repository.setPrefWidth(250.0); repository.setPromptText("Repo"); grid.add(new Label("Repository:"), 0, 0); grid.add(repository, 1, 0); /////////////////////Modification of choose Button//////////////////////// Button chooseButtonType = new Button("Choose"); grid.add(chooseButtonType, 2, 0); // Button btnCancel1 = new Button("Cancel"); // btnCancel1.setPrefWidth(90.0); // Button btnOk1 = new Button("Ok"); // btnOk1.setPrefWidth(90.0); // HBox hbox = new HBox(4); // hbox.getChildren().addAll(btnOk1,btnCancel1); // hbox.setPadding(new Insets(2)); // grid.add(hbox, 1, 1); chooseButtonType.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { // label.setText("Accepted"); File path = chooser.showDialog(dialog.getOwner()); getFileAndSeText(repository,path); chooser.setTitle(resourceBundle.getString("repo")); } }); // btnCancel1.setOnAction(new EventHandler<ActionEvent>(){ // @Override public void handle(ActionEvent e) { // System.out.println("Shyam : Testing"); // setResponse(GitFxDialogResponse.CANCEL); // } // }); ////////////////////////////////////////////////////////////////////// dialog.getDialogPane().setContent(grid); dialog.setResultConverter(dialogButton -> { if (dialogButton == okButton) { String filePath = repository.getText(); //filePath = filePath.concat("/.git"); //[LOG] logger.debug(filePath); if (!filePath.isEmpty() && new File(filePath).exists()) { setResponse(GitFxDialogResponse.OK); return new Pair<>(repository.getText(), GitFxDialogResponse.OK); } else { this.gitErrorDialog(resourceBundle.getString("errorOpen"), resourceBundle.getString("errorOpenTitle"), resourceBundle.getString("errorOpenDesc")); } } if (dialogButton == cancelButton) { //[LOG] logger.debug("Cancel clicked"); setResponse(GitFxDialogResponse.CANCEL); return new Pair<>(null, GitFxDialogResponse.CANCEL); } return null; }); Optional<Pair<String, GitFxDialogResponse>> result = dialog.showAndWait(); result.ifPresent(repoPath -> { //[LOG] logger.debug(repoPath.getKey() + " " + repoPath.getValue().toString()); }); Pair<String, GitFxDialogResponse> temp = null; if (result.isPresent()) { temp = result.get(); } if(temp != null){ return temp.getKey();// + "/.git"; } return EMPTY_STRING; }
Example 18
Source File: MetadataOverview.java From sis with Apache License 2.0 | 4 votes |
private GridPane createSpatialGridPane() { GridPane gp = new GridPane(); gp.setHgap(10.00); gp.setVgap(10.00); int j = 0, k = 1; Collection<? extends ReferenceSystem> referenceSystemInfos = metadata.getReferenceSystemInfo(); if (!referenceSystemInfos.isEmpty()) { ReferenceSystem referenceSystemInfo = referenceSystemInfos.iterator().next(); Label rsiValue = new Label("Reference system infos: " + referenceSystemInfo.getName().toString()); rsiValue.setWrapText(true); gp.add(rsiValue, j, k++); } Collection<? extends SpatialRepresentation> sris = this.metadata.getSpatialRepresentationInfo(); if (sris.isEmpty()) { return gp; } NumberFormat numberFormat = NumberFormat.getIntegerInstance(locale); for (SpatialRepresentation sri : sris) { String currentValue = "• "; if (sri instanceof DefaultGridSpatialRepresentation) { DefaultGridSpatialRepresentation sr = (DefaultGridSpatialRepresentation) sri; Iterator<? extends Dimension> it = sr.getAxisDimensionProperties().iterator(); while (it.hasNext()) { Dimension dim = it.next(); currentValue += numberFormat.format(dim.getDimensionSize()) + " " + Types.getCodeTitle(dim.getDimensionName()) + " * "; } currentValue = currentValue.substring(0, currentValue.length() - 3); Label spRep = new Label(currentValue); gp.add(spRep, j, k++, 2, 1); if (sr.getCellGeometry() != null) { Label cellGeo = new Label("Cell geometry:"); Label cellGeoValue = new Label(Types.getCodeTitle(sr.getCellGeometry()).toString()); cellGeoValue.setWrapText(true); gp.add(cellGeo, j, k); gp.add(cellGeoValue, ++j, k++); j = 0; } } } return gp; }
Example 19
Source File: HTMLEditorSample.java From marathonv5 with Apache License 2.0 | 4 votes |
public HTMLEditorSample() { final VBox root = new VBox(); root.setPadding(new Insets(8, 8, 8, 8)); root.setSpacing(5); root.setAlignment(Pos.BOTTOM_LEFT); final GridPane grid = new GridPane(); grid.setVgap(5); grid.setHgap(10); final ChoiceBox sendTo = new ChoiceBox(FXCollections.observableArrayList("To:", "Cc:", "Bcc:")); sendTo.setPrefWidth(100); GridPane.setConstraints(sendTo, 0, 0); grid.getChildren().add(sendTo); final TextField tbTo = new TextField(); tbTo.setPrefWidth(400); GridPane.setConstraints(tbTo, 1, 0); grid.getChildren().add(tbTo); final Label subjectLabel = new Label("Subject:"); GridPane.setConstraints(subjectLabel, 0, 1); grid.getChildren().add(subjectLabel); final TextField tbSubject = new TextField(); tbTo.setPrefWidth(400); GridPane.setConstraints(tbSubject, 1, 1); grid.getChildren().add(tbSubject); root.getChildren().add(grid); Platform.runLater(() -> { final HTMLEditor htmlEditor = new HTMLEditor(); htmlEditor.setPrefHeight(370); root.getChildren().addAll(htmlEditor, new Button("Send")); }); final Label htmlLabel = new Label(); htmlLabel.setWrapText(true); getChildren().add(root); }
Example 20
Source File: LayersViewPane.java From constellation with Apache License 2.0 | 4 votes |
public LayersViewPane(final LayersViewController controller) { // create controller this.controller = controller; // create layer headings final Label layerIdHeadingText = new Label("Layer\nID"); final Label visibilityHeadingText = new Label("Visibility"); final Label queryHeadingText = new Label("Query"); final Label descriptionHeadingText = new Label("Description"); // create gridpane and alignments layersGridPane = new GridPane(); layersGridPane.setHgap(5); layersGridPane.setVgap(5); layersGridPane.setPadding(new Insets(0, 10, 10, 10)); layersGridPane.addRow(0, layerIdHeadingText, visibilityHeadingText, queryHeadingText, descriptionHeadingText); // set heading alignments GridPane.setMargin(layerIdHeadingText, new Insets(15, 0, 0, 0)); layerIdHeadingText.setTextAlignment(TextAlignment.CENTER); layerIdHeadingText.setMinWidth(40); layerIdHeadingText.setMinHeight(25); layerIdHeadingText.setPrefWidth(30); visibilityHeadingText.setPrefWidth(55); visibilityHeadingText.setMinWidth(50); queryHeadingText.setPrefWidth(10000); queryHeadingText.setMinWidth(80); descriptionHeadingText.setPrefWidth(10000); descriptionHeadingText.setMinWidth(80); // instantiate list of layers layers = new ArrayList<>(); // set default layers setDefaultLayers(); // create options final Button addButton = new Button("Add New Layer"); addButton.setAlignment(Pos.CENTER_RIGHT); addButton.setOnAction(event -> { if (layersGridPane.getRowCount() <= 32) { createLayer(layers.size() + 1, false, "", ""); controller.writeState(); } else { final NotifyDescriptor nd = new NotifyDescriptor.Message( "You cannot have more than 32 layers", NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notify(nd); } event.consume(); }); HBox.setHgrow(addButton, Priority.ALWAYS); final Button deselectAllButton = new Button("Deselect All Layers"); deselectAllButton.setAlignment(Pos.CENTER_RIGHT); deselectAllButton.setOnAction(event -> { for (final LayerDescription layer : layers) { layer.setCurrentLayerVisibility(false); } if (this.layers.isEmpty()) { setDefaultLayers(); } else { setLayers(List.copyOf(layers)); } controller.submit(); controller.execute(); event.consume(); }); HBox.setHgrow(deselectAllButton, Priority.ALWAYS); this.options = new HBox(5, addButton, deselectAllButton); options.setAlignment(Pos.TOP_LEFT); options.setPadding(new Insets(0, 0, 0, 10)); // add layers grid and options to pane this.layersViewPane = new VBox(5, layersGridPane, options); // create layout bindings layersViewPane.prefWidthProperty().bind(this.widthProperty()); options.prefWidthProperty().bind(layersViewPane.widthProperty()); this.setCenter(layersViewPane); controller.writeState(); }