how to repeat a node in same scene in javafx

☆樱花仙子☆ 提交于 2020-01-15 15:40:07

问题


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)


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/31102899/how-to-repeat-a-node-in-same-scene-in-javafx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!