Permutation of scene graph children

Werner Lehmann lehmann at media-interactive.de
Mon Dec 1 18:05:51 UTC 2014


Hi,

occasionally I need to move a child in its children list and would like 
to avoid a remove/add operation. For example, this could be useful to 
change z-order in a StackPane, or change vertical order on a VBox, or 
when synchronizing item order in a model with corresponding node order 
in a skin.

java.util.List does not support a move or swap operation. I had hoped a 
sort operation with a clever comparator might do the trick, triggering a 
permutation listchange event. However, any attempt in this direction 
bombs, complaining about "duplicate children added". On the other hand 
there is rudimentary support for this in Node.toFront and flags exist on 
Parent: "childrenTriggerPermutation", "childSetModified".

Any thoughts about getting swap support on ObservableList and/or 
permutation support on Parent.children?

Werner


More information about the openjfx-dev mailing list