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!

Generic way to add/remove any Node to/from any Parent?

user12215216Oct 23 2014 — edited Oct 24 2014

I am implementing a highly user-customizable (DnD) GUI, for which I need to enable any Node to register itself with any kind of Parent, or to unregister itself from its current Parent. As it seems it is impossible to handle all Nodes in the same way in JavaFX due to the fact that Parent.getChildren() is protected, hence a Node can never do this.getParent().remove(this), or newParent.getChildren().add(this) but must know all possibly existing ways to add children -- like ToolBar.getItems() for example.

I wonder how this shall ever work to deal with all Parents in a generic way. Possible it is wanted to check for @DefaultProperty and uses Reflection to find the needed getter method?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 21 2014
Added on Oct 23 2014
2 comments
1,295 views