带Button的JavaFX.TitledPane

问题描述 投票:2回答:1

是否有可能在JavaFX.Button的标签上添加TitledPaneenter image description here

找到解决方案资料来源:javawiki.sowas.com/doku.php?id=javafx:titledpane-with-checkbox

java javafx javafx-8
1个回答
0
投票
    TitledPane titledPane = new TitledPane(); // or TitledPane(null,content)
    BorderPane borderPane = new BorderPane();
    Label titleOfTitledPane = new Label("SomeText");
    Button buttonClose = new Button("X");
    borderPane.setCenter(titleOfTitledPane);
    borderPane.setLeft(buttonClose);
    borderPane.prefWidthProperty().bind(scene.widthProperty().subtract(40));
    titledPane.setGraphic(borderPane);
© www.soinside.com 2019 - 2024. All rights reserved.