【发布时间】:2016-03-29 16:58:43
【问题描述】:
我想将 SplitPane 的分隔线设置为某个默认位置。这不起作用,分隔线停留在中间:
public void start(Stage primaryStage) throws Exception{
SplitPane splitPane = new SplitPane(new Pane(), new Pane());
// Report changes to the divider position
splitPane.getDividers().get(0).positionProperty().addListener(
o -> System.out.println(splitPane.getDividerPositions()[0])
);
// Doesn't work:
splitPane.setDividerPositions(0.8);
// The docs seem to recommend the following (with floats instead of
// doubles, and with one number more than there are dividers, which is
// weird), but it doesn't work either:
//splitPane.setDividerPositions(0.8f, 0.2f);
primaryStage.setScene(new Scene(splitPane));
primaryStage.setMaximized(true);
primaryStage.show();
}
输出:
0.8
0.5
这表明某些东西将它重置到中间。
我怎样才能做到这一点?
【问题讨论】: