Nodes - Choose the Layer to appear JavaFX2

和自甴很熟 提交于 2019-12-24 17:08:42

问题


I want to be able to choose the layer that the Nodes appear and change it throughout the course of the program.

I know that the last added Nodes appear on the top of the previous one.

In swing, I use JLayeredPane and its method setLayout(JComponent, integer). The higher the int, the higher level the component appears on screen.

Is there something similar?

Thank you


回答1:


I think you can play with the z-order indices of child nodes by combinations of

Node node = pane.getChildren().get(index);
Node node = pane.getChildren().remove(index);
pane.getChildren().add(newIndex, node);



回答2:


A layout has been done to do this job : StackPane.

The JavaFX tutorial has a chapter dedicated to it.

The different pane are stacked but if the opacity is not set to 100 %, they are all visible.



来源:https://stackoverflow.com/questions/12709016/nodes-choose-the-layer-to-appear-javafx2

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