0

I have a 3X3 grid pane. I need to move nodes between cells or remove some nodes at, say, x,y position. In doing so I want the remaining nodes to get rearranged accordingly. Like if I remove the first node, the node at cell 0,1 should occupy 0,0 and so on..

I am doing this by DnD. Is there any way to auto arrange the cell nodes, rather than using custom logic on the drop event?

Sheikh
  • 539
  • 1
  • 7
  • 29
Saju
  • 402
  • 3
  • 11
  • 30
  • Would using a [`TilePane`](http://docs.oracle.com/javase/8/javafx/api/javafx/scene/layout/TilePane.html) work better than a `GridPane`? – James_D Aug 19 '14 at 15:18
  • @James_D Thanks for pointing to TilePane. I modified my code using this. But i need a fixed column layout. Now in this case, after setting preferred column to 3, the column count increases to 5. It is not possible to reduce size of container or to increase size of node. Is there any way to fix the column count. – Saju Aug 20 '14 at 04:24
  • Bit tricky. You can try binding the `prefTileWidth`. Something like `tilePane.prefTileWidthProperty().bind(tilePane.widthProperty().divide(3).subtract(1));` – James_D Aug 20 '14 at 15:26
  • Maybe the `ButtonGrid`shown at http://stackoverflow.com/questions/36831753/tilepane-with-automatically-stretching-tiles-in-javafx/36831899#36831899 can help you – jns May 14 '16 at 16:59

0 Answers0