我在.fxml文件中創建了TreeView,然後我試圖顯示根節點。但沒有顯示。在TreeView中沒有顯示根節點(TreeItem)
這是我的代碼。
<TabPane prefHeight="289.0" prefWidth="246.0" styleClass="tab-pane" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<stylesheets>
<URL value="@main.css" />
</stylesheets>
<tabs>
<Tab text="TestBed Explorer">
<content>
<AnchorPane id="Content" fx:id="soariteAnchorScollparent" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<ScrollPane fx:id="soariteTreeScrollPane" prefHeight="259.0" prefWidth="246.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<AnchorPane id="Content" fx:id="soariteTreeAnchorPane" minHeight="0.0" minWidth="0.0" prefHeight="249.0" prefWidth="73.0">
<children>
<TreeView fx:id="soariteTree" prefHeight="245.0" prefWidth="79.0" showRoot="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="167.0" AnchorPane.topAnchor="0.0">
<TreeItem expanded="true" value="categories" fx:id="rootTreeItem" />
</TreeView>
</children>
</AnchorPane>
</content>
</ScrollPane>
</children>
</AnchorPane>
</content>
</Tab>
</tabs>
</TabPane>
我也給這個主要類的參考喜歡。
public class Mainextends Application {
@FXML
public TreeView<String> soariteTree;
@FXML
public TreeItem<String> rootTreeItem;
請給我任何參考或提示。
你可以再做一個幫助....如何在此上添加鼠標右鍵點擊樹? –
是你的問題解決了,然後把這個標記爲正確的答案,並且肯定會嘗試點擊右鍵並在以後發帖 –
是的..你解決了我的問題..至少20小時需要獎勵賞金... –