我想將節點添加到TitledPane
的標題中。我發現這樣做的唯一方法是使用setGraphic()
方法。JAVAFX - 將節點添加到TitledPane的標題
的代碼
TitledPane tpane = new TitledPane();
tpane.setContent(new Text("Content"));
tpane.setExpanded(false);
Button b = new Button("Delete");
BorderPane box = new BorderPane();
box.setLeft(new Text("1 "));
box.setCenter(new Text("Single Pane"));
box.setRight(b);
AnchorPane par = new AnchorPane(box);
tpane.setGraphic(par);
VBox vbox = new VBox();
vbox.getChildren().add(tpane);
目標
我想把Delete
按鈕向右,這就是爲什麼我使用Borderpane
。所以BorderPane
需要填寫整個TitledPane
的標題寬度減去小三角形的空間
怎樣才能在setGraphic()
方法內完成?或者有沒有更好的方法來實現它?
我假設你試過沒有錨窗格然後包裹邊框窗格。同樣的結果? –
@James_D我做了,沒有什麼不同。 – KeepMove