3

here is my code:

    def list = FXCollections.observableArrayList([])
    GridView<Color> g = new GridView<>(list);
    g.setCellFactory(new Callback<GridView<Color>, GridCell<Color>>() {
        public GridCell<Color> call(GridView<Color> gridView) {
            return new ColorGridCell();
        }
    });
    Random r = new Random(System.currentTimeMillis());
    for (int i = 0; i < 50; i++) {
        list.add(new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), 1.0));
    }

see my screenshot, the left padding and right padding is diff, how to align Gridview to center

enter image description here

tim_yates
  • 167,322
  • 27
  • 342
  • 338
chikadance
  • 3,591
  • 4
  • 41
  • 73

1 Answers1

1

GridView flows cells automatically based on its width and height. The reason you have more space on the right is that the column of cell does not quite fit into it yet. Try to resize the window horizontally and you will see what I mean.

Eugene Ryzhikov
  • 17,131
  • 3
  • 38
  • 60