Question

I have this TreeView in my .fxml file:

<TreeItem fx:id="homenizerTree" value="Mein Homenizer" expanded="true" >
     <children>
          <TreeItem fx:id="addressbookTree" value="Adressbuch" />
          <TreeItem fx:id="dateTree" value="Termine"/>
          <TreeItem fx:id="toDoTree" value="Aufgaben"/>
          <TreeItem fx:id="financeTree" value="Finanzen"/>
     </children>
</TreeItem>    

In my .css file I want to set a image to my TreeItems:

#addressbookTree {
  -fx-graphic: url("../../resources/images/addressFolder.png"); 
}

But this does not work.

I searched via google, but didn't find a answer.

I noticed that I can change the image, background color, etc. of a TreeCell Object, but I don't know how to use a TreeCell Object in FXML.

How can I set the image for a specific TreeItem?

No correct solution

OTHER TIPS

After finding this similar question, I was able to accomplish my goal with the following FXML markup:

<TreeItem expanded="false" value="Root" fx:id="rootItem">
    <graphic>
        <ImageView>
            <image>
                <Image url="icons/icon_folder.png" />
            </image>
        </ImageView>
    </graphic>
</TreeItem>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top