Nodes - Choose the Layer to appear JavaFX2

2019-08-08 19:21发布

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

2条回答
甜甜的少女心
2楼-- · 2019-08-08 19:35

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);
查看更多
女痞
3楼-- · 2019-08-08 19:45

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.

查看更多
登录 后发表回答