private GridPane getNewGrid() { GridPane grid = new GridPane(); grid.setVgap(10); grid.setHgap(5); // grid.setGridLinesVisible(true); grid.paddingProperty().set(new Insets(5)); // GridPane.setVgrow(grid, Priority.ALWAYS); // grid.setMinWidth(500); ColumnConstraints col = new ColumnConstraints(); col.setMinWidth(10); col.setHgrow(Priority.SOMETIMES); col.setFillWidth(true); // col.setPercentWidth(1); col.setPrefWidth(100); grid.getColumnConstraints().addAll(col, col); // ------ RowConstraints row1 = new RowConstraints(); RowConstraints row2 = new RowConstraints(); row1.setMinHeight(10); row1.setVgrow(Priority.SOMETIMES); row1.setFillHeight(true); row1.setPrefHeight(30); row2.setMinHeight(10); row2.setVgrow(Priority.SOMETIMES); row2.setFillHeight(true); row2.setValignment(VPos.CENTER); grid.getRowConstraints().addAll(row1, row2); // ColumnConstraints c = new ColumnConstraints(); // c.setHgrow(Priority.SOMETIMES); // c.setMaxWidth(173.0); // c.setMinWidth(10.0); // c.setPrefWidth(124.0); // grid.getColumnConstraints().add(c); // c = new ColumnConstraints(); // c.setHalignment(HPos.RIGHT); // c.setHgrow(Priority.NEVER); // grid.getColumnConstraints().add(c); // RowConstraints r = new RowConstraints(); // r.setVgrow(Priority.NEVER); // grid.getRowConstraints().add(r); return grid; }
public <T extends Field> T addField(String fieldName, T field) { Validate.notNull(field); field.setName(fieldName); final String caption = AnnotationUtils.getFieldCaption(MODEL_CLASS, fieldName); final RowConstraints row = new RowConstraints(); row.setFillHeight(Boolean.TRUE); row.setValignment(VPos.TOP); getGridPane().getRowConstraints().addAll(row); getGridPane() .addRow( getController().getFields().size(), new Label(caption), getController().registerField(field, fieldName).getUI()); return field; }
public final void initCanvas(int cols, int rows) { this.currentPad = 0; this.canvasPads.clear(); this.getChildren().clear(); double widthFactor = 1.0 / cols; double heightFactor = 1.0 / rows; GridPane grid = new GridPane(); for (int c = 0; c < cols; c++) { for (int r = 0; r < rows; r++) { TEmbeddedPad pad = new TEmbeddedPad(); this.canvasPads.add(pad); pad.widthProperty().bind(this.widthProperty().multiply(widthFactor)); pad.heightProperty().bind(this.heightProperty().multiply(heightFactor)); grid.add(pad, c, r); } } ColumnConstraints cc = new ColumnConstraints(); // cc1.setPercentWidth(50); cc.setHgrow(Priority.ALWAYS); cc.setFillWidth(true); for (int c = 0; c < cols; c++) { grid.getColumnConstraints().add(cc); } RowConstraints rc = new RowConstraints(); rc.setFillHeight(true); rc.setVgrow(Priority.ALWAYS); for (int r = 0; r < rows; r++) { grid.getRowConstraints().add(rc); } this.getChildren().add(grid); // grid.prefWidthProperty().bind(this.widthProperty()); // grid.prefHeightProperty().bind(this.heightProperty()); // GridPane grid = new GridPane(); // pad.widthProperty().bind(this.widthProperty()); // pad.heightProperty().bind(this.heightProperty()); }