示例#1
0
  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;
  }
示例#2
0
文件: View.java 项目: jimmor/whale
 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;
 }