JavaFX 8 错误的 SplitPane 的分隔符位置

标签 java javafx javafx-8 splitpane

我使用内部有 4 个节点的 splitPane,没有大小限制。但是当我尝试拆分它时,它不起作用。

使用的代码

m_Split.setDividerPosition(0, 0.25);
m_Split.setDividerPosition(1, 0.5);
m_Split.setDividerPosition(2, 0.75);
double tab[] = m_Split.getDividerPositions();
for(int i=0; i < tab.length; i++)
{
    System.out.println("i=" + i + "  pos=" + tab[i]);
}

代码位于以 Platform.runLater(new Runnable) 和 run() 函数开头的函数中。

输出

i= 0  pos=0.2505854800936768
i= 1  pos=0.5
i= 2  pos=0.7505854800936768

但与其他人的位置值

i=0  pos=0.2997658079625293
i=1  pos=0.5
i=2  pos=1.0

0.3、0.6 和 1.0 和

i=0  pos=0.5
i=1  pos=0.5
i=2  pos=1.0

具有 0.5、1.0 和 1.0 值

我使用Java 1.8Java FX 8

谢谢

最佳答案

您没有给出完整的示例来重现您的问题,因此我们只能猜测。您描述的问题最可能的原因是您已将子项添加到分割 Pane 中,并且它们的最大/最小尺寸与您的分隔符约束不兼容。 javadoc状态(强调我的):

Setting the divider position greater than the node's maximum size position will result in the divider being set at the node's maximum size position. Setting the divider position less than the node's minimum size position will result in the divider being set at the node's minimum size position. Therefore the value set in setDividerPosition(int, double) and setDividerPositions(double...) may not be the same as the value returned by getDividerPositions().

关于JavaFX 8 错误的 SplitPane 的分隔符位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25969351/

相关文章:

Java 服务器在使用 Javafx 单击按钮时停止

JavaFX 错误 : Controller value already specified

java - 如何从多个嵌套 FXML 获取数据并调用其 Controller 上的方法

java - 观察文件夹结构的变化并相应地处理文件

java - 为什么 JavaFX WebView 不允许视频全屏模式

java - 生成 N x N 网格

java - 将封底附加到卡片图像上

java - 传递函数的所有参数

java - onmessage Google App Engine (Java) channel API

java - 使用资源插件从相邻的 Maven 模块复制静态文件和目录?