0

I have a gridpane with 2 rows and 2 cols. The user should be able to change the column width on the UI dynamically (best with the mouse on the divider). But I haven't found a way to do that.

Can this be done using a gridpane or would I have to use a splitpane as in Resizeable Gridpane or other container with e.g. nested vboxes in each pane?

Thanks in advance, Thomas

2 Answers2

1

I think for just a two by two grid the easiest solution would be to use three nested Split panes. A major vertical one which is then again subdivided by two minor horizontal ones (or vize versa). You just have to be carefull to synchronize the two minor ones so that they move in parallel.

mipa
  • 10,369
  • 2
  • 16
  • 35
0

For completeness, here is what I did in the end:

I have a 2x2 gridpane and the resize divider should only be visible in the lower row. So I added a splitpane with two regions into the gridpanes second row that spans both columns. I moved the inner controls from the gridpane onto the splitpane.

Now I only neeeded to sync the movement of the splitpane divider with the gridpane via a

mySplitPane.getDividers().get(0).positionProperty().addListener((observable, oldValue, newValue)

Also, another listener is needed to fix JavaFX - SplitPane, resize & proportions issue. This one sets the divider position after resize of the gridpane:

myGridPane.widthProperty().addListener((observable, oldValue, newValue)