带Button的JavaFX.TitledPane

时间:2018-03-03 15:31:35

标签: java javafx javafx-8

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

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

1 个答案:

答案 0 :(得分: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);