简体   繁体   中英

JavaFX.TitledPane with Button

Is it possible to add a JavaFX.Button on a Label of TitledPane ? 在此处输入图片说明

Solution found! Source: 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM