带有StackPane和自定义控件的Javafx TabPane [英] Javafx TabPane with StackPane and custom Controls

查看:708
本文介绍了带有StackPane和自定义控件的Javafx TabPane的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发JAVAFX中的应用程序。主要是,该应用程序使用 TabPane 控制器。在第一个选项卡中,我正在为 StackPane 加载控制器。在 StackPane 我正在加载一个默认的,一个包含自定义单元格的列表视图。在每个单元格中我都有一些按钮。我想在堆栈窗格中添加一个新窗格,并在单击按钮时将其置于前面。
我尝试使用 toFront() toBack()但我无法正常工作。
我检查了,两个窗格都已加载,其内容是正确的。
我无法附上照片,因为我没有足够的代表。

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.

任何建议都表示赞赏。

推荐答案

很难确切地知道出现了什么问题,因为你没有发布任何代码,而是来自 StackPane Javadocs

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


子项的z顺序由子项
列表的顺序定义,其中第0个孩子是最下面的孩子,最后一个孩子在最上面。如果设置了
边框和/或填充,则子项将在这些插入内部布置

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.

所以要将 Node 移到前面,你应该把它移到列表的末尾:

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

这篇关于带有StackPane和自定义控件的Javafx TabPane的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆