是否可以在JavaFX.Button的标签上添加TitledPane
java - 带按钮的JavaFX.TitledPane-LMLPHP

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

最佳答案

    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);

07-24 18:50