就像显示的图片一样,上方的红色框是GridBox,下方的是带有Splitpane(ListView)和Gridpane(2个按钮)的VBox。我要实现的是单击“隐藏<<<”按钮时隐藏下面的VBox。
但是现在,通过调用root.getChildren()。remove(child);可以删除下面的红色框。窗口(舞台)或场景如何自动调整大小。
在控制器中:
public class FunctionOwnerFX extends Application{
public static String HIDE = "Hide Libraries <<<";
public static String SHOW = "Show Libraries >>>";
private boolean isHidden = false;
@FXML
private TextField textfield;
@FXML
private Button btn2;
@FXML
private VBox vbox;
@FXML
private VBox libraryVbox;
private Stage primaryStage;
@Override
public void start(Stage stage) throws Exception{
primaryStage = stage;
Parent root = FXMLLoader.load(getClass().getResource("new_function_owner.fxml"));
Scene scene = new Scene(root);
stage.setTitle("New Function Owner");
stage.setScene(scene);
stage.sizeToScene();
stage.show();
}
@FXML
protected void splitPaneControl(){
isHidden = …Run Code Online (Sandbox Code Playgroud)