Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Replacing row content in GridPanes

restenbroNov 26 2012 — edited Nov 28 2012
I have a GridPane where I want to be able to seamlessly add rows, delete rows, and change row indices.

For example, I want to be able to "push" a new item in at the top of the GridPane, subsequently pushing all other rows down by one index.

The GridPane class does not have any replace() method or interface to my knowledge. I can reference the individual nodes in the Pane, so I suspect one possible solution would be to use getRowIndex(Node), and then update all the nodes on that row directly (all I need is a Label.setText). However, due to the size of the Pane, it would not really be desirable to run all this code on the application thread. For a MxN pane, I would have to loop through N lists of M nodes, looking for the right row, then updating, and repeat this for all nodes, for a total of MxN updates.

Another solution might be to just redraw the entire GridPane with updated information, dump the current scene, and redraw with a new scene containing the updated GridPane.

So it can be done, but I think both suggested approaches seem a bit kludgy, and was wondering if anybody could suggest a more elegant solution.
This post has been answered by James_D on Nov 27 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 26 2012
Added on Nov 26 2012
11 comments
13,350 views