问题
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