Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm developing an app in JAVAFX. Mainly, the app is using a TabPane controller. In the first tab, i'm loading a controller for a StackPane. In the StackPane i'm loading as a default, one list view with custom cells. In each cell i'm having some buttons. I want to add a new pane in the stack pane and bring it to front when a button is clicked. I tried with the toFront() and toBack() but i can't get anything working. I've check, and both panes are loaded and their content is the right one. I can't attach photos because i don`t have enough rep.

Any suggestion is appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
273 views
Welcome To Ask or Share your Answers For Others

1 Answer

It's hard to know exactly what's going wrong since you didn't post any code, but from the StackPane Javadocs:

The z-order of the children is defined by the order of the children list with the 0th child being the bottom and last child on top. If a border and/or padding have been set, the children will be layed out within those insets.

So to move a Node to the front, you should move it to the end of the list:

StackPane stackPane = ... ;
Node node = ... ;

// move node to front:

// remove node from current location in child list"
stackPane.getChildren().remove(node);
// add node back in at end of child list:
stackPane.getChildren().add(node);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...