deltascience
deltascience

Reputation: 3390

Can't change Tree icon in Vaadin

I use Vaadin 7. I tried to change the component's icon with the following code :

Tree tree = new Tree("The Planets and Major Moons");
tree.setIcon(new ThemeResource("img/inode-directory.png"));
.... //here I fill the tree

When I run the application I still get the same icon (default icon) of Vaadin Tree. Is there something that I forgot to add?

Upvotes: 0

Views: 1147

Answers (1)

deltascience
deltascience

Reputation: 3390

I figured how to change to tree icon in Vaadin. It's simple :

  • You have to create you own custom Theme that inherit from the default theme here
  • Override the following CSS in your style.css : .v-tree-node and .v-tree-node-expanded

You can set any img you want from an url like this :

.v-tree-node-expanded {
background: transparent url(img/Documenta.png) no-repeat 0px 4px;
}
.v-tree-node {
background: transparent url(img/Documenta.png) no-repeat 0px 4px;
padding: 1px 0;
padding-left: 2px;
}

Upvotes: 1

Related Questions