I have a GridPane for which I change the row/column arrangement when the
window resizes.  If GridPane components had attached properties for their
grid coordinates, I'd just change the properties.  But instead I guess I
have to clear the pane and lay it out afresh, building it up row by row
(which, may I say, is a little bit tedious in comparison to the WPF approach
to containers).  I have all the components already pre-built and stored in a
master list, so I thought I could just do

  pane.clear();
  doMyGridLayout(pane, components);

However, when I do that, I get an exception in
GridPane$Row.insert: "Component already has a parent."

So instead of calling clear, I have to do something like this:

RowSequence gridRows = pane.getRows();
gridRows.remove(0, gridRows.getLength());

as, apparently, RowSequence does know how to unparent its children (not that
this is so painful -- I initially feared I'd have to remove my components
one by one).

Am I missing something, or did GridPane forget to override clear() and do
something reasonable?

(I haven't tried it, but I'm wondering if the same question could be asked
of TablePane.)

Reply via email to