how to repeat a node in same scene in javafx

2019-08-02 13:52发布

I want to repeat one node in scene . Is it possible ? for example I have an anchorpane and 3 panes on it . I have one button on pane(1) and I want to add it to pane(2) after some process in program ... . I want to repeat that node exactly like the old one( with same properties)

2条回答
狗以群分
2楼-- · 2019-08-02 14:31

Only one Node appears on the scene graph, if you want to have same scene manipulating several times on the scene, then you gona have to try the hard way by creating other nodes with similar content like the one you want to repeat on the scene graph. Adding them to the scene will look like the same Node on the scene.

I don't other way of doing it,more answers and corrections are welcome. Sorry to respond to this old qtn

查看更多
你好瞎i
3楼-- · 2019-08-02 14:43

No, you cannot repeat the same node in a scene.

From the Node Javadocs :

A node may occur at most once anywhere in the scene graph. Specifically, a node must appear no more than once in all of the following: as the root node of a Scene, the children ObservableList of a Parent, or as the clip of a Node.

Answering your question :

I want to repeat that node exactly like the old one

To achieve this, create a styleclass and add it to similar nodes that you want to create.

查看更多
登录 后发表回答