Clone JavaFX Node?

前端 未结 2 841
悲哀的现实
悲哀的现实 2020-12-20 12:27

I have created a Node (AnchorPane) in the JavaFX scene builder and was wondering how to clone it.

I saw Duplicate/Clone Node in JavaFX 2.0

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-20 13:14

    There is no such node duplication function in the JavaFX platform, you will need to write your own which introspects on the properties of the node you are interested in cloning and creates a new node with the required properties.

    Using an fxml template for the node definition is probably the easiest way to do this for node's with static initialization properties - but then, as you state in your question, you don't want to use fxml for this, so you'll have to code your cloning logic in Java.

提交回复
热议问题