我有一个包含两个项目的SplitPane:进度条(顶部窗格)和操作按钮(例如,ok / cancel)作为底部窗格。 加载页面时,将显示两个窗格。 在初始加载期间,我希望隐藏顶部窗格并显示底部窗格。 通过按钮单击发生操作事件时,将显示顶部窗格。 我应该如何修改代码以便能够执行所描述的场景
FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import com.ngc.gs.dialogs.widgets.*?>
<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<AnchorPane fx:id="progressMainAnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="390.0002999999924" prefWidth="398.9998779296875" xmlns:fx="http://javafx.com/fxml" fx:controller="com.ngc.gs.dialogs.widgetexample.MyCheckBoxSelController">
<TreeView fx:id="localTreeView" prefHeight="181.0" prefWidth="363.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="21.0" AnchorPane.topAnchor="14.0" />
<SplitPane fx:id="progressSplitPane" focusTraversable="true" maxWidth="1.7976931348623157E308" orientation="VERTICAL" prefHeight="181.0" prefWidth="362.999755859375" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="21.0" AnchorPane.topAnchor="195.0">
<items>
<ProgressBarMessageConsoleWidget id="pBarConsoleWidget" fx:id="pBarConsoleWidget" minHeight="150.0" minWidth="0.0" prefHeight="150.0" prefWidth="361.0" />
<OkCancelButtonsWidget id="actionButtonsWidget" fx:id="actionButtonsWidget" minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" />
</items>
</SplitPane>
<stylesheets>
<URL value="@../styles/dialogs.css" />
</stylesheets>
</AnchorPane>
设置splitPane分隔符的Controller类片段:
....
progressSplitPane.setDividerPosition(0, 0.0);
progressSplitPane.setResizableWithParent(progressMainAnchorPane, true);
actionButtonsWidget.getOkBtn().setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent evnt) {
// Show progress bar and message console
progressSplitPane.setDividerPosition(0, 0.75);
pBarConsoleWidget.showProgressConsole();
processCheckBoxSelections();
}
});
...