# dbTreeView set selected row background color

**URL:** <https://forum.servoy.com/t/dbtreeview-set-selected-row-background-color/19659>\
**Category:** Classic Servoy\
**Created:** [April 19, 2018, 6:14pm UTC](https://forum.servoy.com/t/dbtreeview-set-selected-row-background-color/19659 "2018-04-19T18:14:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![huber](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/huber/32/5042_2.png) [@huber](https://forum.servoy.com/u/huber)\
**Post date:** [April 19, 2018, 6:14pm UTC](https://forum.servoy.com/t/dbtreeview-set-selected-row-background-color/19659/1 "2018-04-19T18:14:40Z")

</div>

Hi

I’d like to set in the dbTreeView bean the selected row background color. How can this be accomplished?

Regards,

---

<div class="post-metadata">

**Author:** ![Gabi\_Boros](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@Gabi\_Boros](https://forum.servoy.com/u/Gabi_Boros)\
**Post date:** [April 20, 2018, 11:30am UTC](https://forum.servoy.com/t/dbtreeview-set-selected-row-background-color/19659/2 "2018-04-20T11:30:29Z")

</div>

hi,

in which application type? for web it should work be overriding the CSS used for selection color, in the smart client it uses the color from the active LAF

---

<div class="post-metadata">

**Author:** ![huber](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/huber/32/5042_2.png) [@huber](https://forum.servoy.com/u/huber)\
**Post date:** [April 20, 2018, 12:32pm UTC](https://forum.servoy.com/t/dbtreeview-set-selected-row-background-color/19659/3 "2018-04-20T12:32:28Z")

</div>

Hi Gabi

It’s for the Smart Client. As you say, the active LAF background color is used, but I would like to use another one.

BTW, is there still no way to control the space between the start of text and the left side (or the triangle)? And also no possibility to span the selected background color over the whole width of the dbTreeView bean? Yes I know the Smart Client has (unfortunately) no priority at Servoy, but still customers expect to have an attractive UI and years of work gone into Smart Client applications can’t easely thrown away.

> Gabi Boros:  
> hi,
> 
> in which application type? for web it should work be overriding the CSS used for selection color, in the smart client it uses the color from the active LAF

Best regards,

---

<div class="post-metadata">

**Author:** ![Gabi\_Boros](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@Gabi\_Boros](https://forum.servoy.com/u/Gabi_Boros)\
**Post date:** [April 20, 2018, 1:03pm UTC](https://forum.servoy.com/t/dbtreeview-set-selected-row-background-color/19659/4 "2018-04-20T13:03:09Z")

</div>

the thing is, the dbtreeview on smart client is actually a wrapper around java’s swing tree control, and so, if there is no setting/support for  
a desired UI change, we can’t do it either (this is related to “no way to control the space between the start of text and the left side / no possibility to span the selected background color over the whole width”),  
but the best way is, if you create a case, so we can have a look.  
as for the background/foreground, you could try to change the LAF colors on solution open

```auto
	var foregroundColor = new Packages.javax.swing.plaf.ColorUIResource(Packages.java.awt.Color.decode('#00ffff'));
	var backgroundColor = new Packages.javax.swing.plaf.ColorUIResource(Packages.java.awt.Color.decode('#ff0000'));
	var uiDefaults = Packages.javax.swing.UIManager.getDefaults();
	uiDefaults.put("Tree.selectionBackground", backgroundColor);
	uiDefaults.put("Tree.selectionForeground", foregroundColor);

```

---

<div class="post-metadata">

**Author:** ![huber](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/huber/32/5042_2.png) [@huber](https://forum.servoy.com/u/huber)\
**Post date:** [April 20, 2018, 1:24pm UTC](https://forum.servoy.com/t/dbtreeview-set-selected-row-background-color/19659/5 "2018-04-20T13:24:33Z")

</div>

Thanks for your help, Gabi! And your suggestion of changing the LAF color.

The desire would be to give a bg color to each dbTreeView separatly, see attache screenshot. The main menu tree on the left should use the LAF color, the one on the right should have a light blue.

I will try your hint, thanks. And make a case.  
Regards

 ![menu.png](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/0/01a06df5b47c86df6df52a622c8c1c2ea6b04032.png)
