1

I am working with a GridPane layout and I require it to (by default) have a fixed number of rows and columns. In certain situations, I would like the GridPane to expand in the number of rows and columns. I would like the GridPane to have an extra row/column by placing an entire empty row/column on the outer sides of the GridPane.

This feature exists in the JavaFX Scene Builder by right clicking on the GridPane and selecting GridPane, then it will show a list of options: Add Row Above, Add Row Below, Add Column After, Add Column Before. The results of each of these options are what I desire. But I have looked through the API and there does not seem to be any relevant behaviour.

If there is a layout that you seem will work, please let me know!

P.S., I would like to post an image to show what I mean but I do not have 10 reputation posts. :( The instructions has been listed above or here: https://i.stack.imgur.com/jgdjb.png

Thank you very much, Matt

Matt
  • 41
  • 1
  • 4
  • It's not really clear what you're asking. Doesn't [`gridPane.add(Node child, int columnIndex, int rowIndex);`](http://docs.oracle.com/javase/8/javafx/api/javafx/scene/layout/GridPane.html#add-javafx.scene.Node-int-int-) do what you want, as long as you pick the correct value for the row and column indexes? – James_D Aug 25 '14 at 01:22
  • I would like to insert an entire row or column at any place and once that happens, the existing rows and columns should be shifted accordingly. Would that work as intended using the method you mentioned? – Matt Aug 25 '14 at 01:32
  • Everything else will retain its current coordinates in the grid. So if you wanted to place an extra row/column in the middle somewhere, you'd have to reorganize existing nodes, but you said "outer edge", so it should work easily. – James_D Aug 25 '14 at 01:44
  • Thank you for your responses! I have been able to add it through positive indices. However, if I specify negative values for the row and column it would throw an error. The reason I am using negative values for rows is because I want to place at the far top or place a column at the far left of the GridPane. i.e, GridPane.add(..., -1, 0); – Matt Aug 25 '14 at 04:49
  • @Matt As @James_D said `if you wanted to place an extra row/column in the middle somewhere, you'd have to reorganize existing nodes, but you said "outer edge" ...`. Top and Left are not `outer edges`. If you want to add a row at the top or a column at the extreme left, you will have to re-arrange the entire table ! – ItachiUchiha Aug 25 '14 at 06:46
  • @ItachiUchiha that is a wonderful suggestion! I have an idea now on the implementation of it. Thank you both of you for your great help! :) – Matt Aug 25 '14 at 13:42
  • You could also just start with everything in (for example) columns numbered from 1, so that you can add something in column 0... – James_D Aug 25 '14 at 17:43

0 Answers0