Copy constructors

Werner Lehmann lehmann at
Mon Sep 10 07:47:00 PDT 2012

I am not sure how an include would help much here. Consider this scenario:

   <GridPane fx:id="gp">...</GridPane>

<VBox fx:id="vbox"/>

Now, if I wanted to add N gridpanes much like the one from the define 
block as children of the vbox - in code, in a for loop, with some 
adjustments... how would I do this with fx:include?

Obviously an fx:include instead of fx:define does not help. It would not 
be dynamic. I could also put the define in a separate fxml and load that 
one 10 times. Certainly doable and does not need fx:include. Hardly 
elegant though, and I'd like to keep it in one file anyway.

Thinking about it, there is not really even a need for a copy 
constructor which would deep-copy an otherwise useless template 
instance. It would be even better if the instantantion of the fx:define 
piece could be delayed, and would be repeatable in a loop:

@FXML private VBox vbox;

for (item: list) {
   GridPane gp = loader.instantiate("gp");

I realize that chances to get this are slim. However, at least in my 
code it is somehow a pattern on several occasions, forcing me to leave 
FXML for dynamic content.



On 10.09.2012 13:15, Greg Brown wrote:
> I don't know if there are any plans to add copy constructors, but you
> might be able to do something similar with includes (e.g. instead of
> defining your template in a define block, you could define it in an
> external FXML file and include it where needed).

More information about the openjfx-dev mailing list