Javafx TabPane with StackPane and custom Controls

拥有回忆 提交于 2019-12-25 17:26:06

问题


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.


回答1:


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);


来源:https://stackoverflow.com/questions/26710777/javafx-tabpane-with-stackpane-and-custom-controls

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