# Customizing Tag Browse Tree

**URL:** <https://forum.inductiveautomation.com/t/customizing-tag-browse-tree/28755>\
**Category:** Ignition\
**Created:** [October 2, 2019, 3:18pm UTC](https://forum.inductiveautomation.com/t/customizing-tag-browse-tree/28755 "2019-10-02T15:18:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![koryk](https://avatars.discourse-cdn.com/v4/letter/k/cdc98d/32.png) [@koryk](https://forum.inductiveautomation.com/u/koryk)\
**Post date:** [October 2, 2019, 3:18pm UTC](https://forum.inductiveautomation.com/t/customizing-tag-browse-tree/28755/1 "2019-10-02T15:18:51Z")

</div>

Hi Paul,

I’m not sure if I should start a new thread or not, but I’m having a weird issue with the Tag Browse Tree fonts as well. I have 2 buttons on a screen, one to increase the font by 2, the other to decrease it by 2. The code behind the buttons works fine in Designer, so I deployed it to the production system (running windows), but this morning when I tested it in my dev environment (Ubuntu), it still works in designer, but does not work when I launch a client.

I had to add the .visible flag and .showRootNode flags to get the Tag Browse Tree to refresh properly (that is the only reason it is in the code).

I’ve also played with the Script Editor for mouseClicked, mousePressed, and mouseReleased thinking it could be a race condition somewhere as when I run it in the Linux client, if I hit the Font minus button, some times it increases…

Thoughts?

```auto
from java.awt import Font
#Forcing the showRootNode and visible flags to 0, then to 1
#forces a refresh of the font.
event.source.parent.getComponent('Tag Browse Tree').visible = 0
event.source.parent.getComponent('Tag Browse Tree').showRootNode = 1
oldfontplus = event.source.parent.getComponent('Tag Browse Tree').font
sizenewplus = oldfontplus.size + 2
newFontplus = Font('Dialog',0,sizenewplus)
#newFontplus = oldfontplus.deriveFont(sizenewplus)
event.source.parent.getComponent('lblFontSize').text = "Size = %s" % str(int(sizenewplus))
event.source.parent.getComponent('Tag Browse Tree').font = newFontplus
event.source.parent.getComponent('Tag Browse Tree').showRootNode = 0
event.source.parent.getComponent('Tag Browse Tree').visible = 1

```

---

<div class="post-metadata">

**Author:** ![koryk](https://avatars.discourse-cdn.com/v4/letter/k/cdc98d/32.png) [@koryk](https://forum.inductiveautomation.com/u/koryk)\
**Post date:** [October 2, 2019, 6:59pm UTC](https://forum.inductiveautomation.com/t/customizing-tag-browse-tree/28755/2 "2019-10-02T18:59:40Z")

</div>

@paul-griffith, I also found another forum entry for changing the colors, so I tried modifying that code as well (works fine in Designer, but not in the Vision Client):

```auto

from javax.swing.tree import DefaultTreeCellRenderer
from javax.swing.plaf import FontUIResource
cellRenderer = DefaultTreeCellRenderer()
btr = system.gui.getParentWindow(event).getComponentForPath("Root Container.Tag Browse Tree")
oldfont = (event.source.parent.getComponent('Tag Browse Tree').font).size
newFont = FontUIResource('Dialog',0,(oldfont-2))
cellRenderer.setFont(newFont)
btr.viewport.view.setFont(newFont)
btr.setFont(newFont)

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 2, 2019, 7:07pm UTC](https://forum.inductiveautomation.com/t/customizing-tag-browse-tree/28755/3 "2019-10-02T19:07:33Z")

</div>

@koryk  
I moved these posts to a new thread, just to make it easier to track.

I don’t have any great advice - it _seems_ like what you’re doing should be working, without diving into it myself. It’s possible that a `repaint()` event is being fired (most likely, by the `showRootNode`/`visible` property changes) and on repaint, the component is resetting the font settings to default.

---

<div class="post-metadata">

**Author:** ![koryk](https://avatars.discourse-cdn.com/v4/letter/k/cdc98d/32.png) [@koryk](https://forum.inductiveautomation.com/u/koryk)\
**Post date:** [October 2, 2019, 7:32pm UTC](https://forum.inductiveautomation.com/t/customizing-tag-browse-tree/28755/4 "2019-10-02T19:32:30Z")

</div>

Thanks for looking. I’ve opened a ticket with support.

Kory

---

<div class="post-metadata">

**Author:** ![koryk](https://avatars.discourse-cdn.com/v4/letter/k/cdc98d/32.png) [@koryk](https://forum.inductiveautomation.com/u/koryk)\
**Post date:** [October 2, 2019, 10:30pm UTC](https://forum.inductiveautomation.com/t/customizing-tag-browse-tree/28755/5 "2019-10-02T22:30:53Z")

</div>

So, after much troubleshooting with Inductive Automation tech support (thanks Tyler!), reading the font back before adding 2 to the size was the issue. It seems to reads from a different location, or it reads before the new changes have propagated throughout the Gateway. To correct this behaviour, I added a Custom Property to the Root Container called storedFont (type integer), and set the default value to 12. Then I execute the following on a button:

```auto
from javax.swing.tree import DefaultTreeCellRenderer
from javax.swing.plaf import FontUIResource
cellRenderer = DefaultTreeCellRenderer()
btr = system.gui.getParentWindow(event).getComponentForPath("Root Container.Tag Browse Tree")
savedFontSize = event.source.parent.storedFont
newFontSize = savedFontSize + 2
event.source.parent.storedFont = newFontSize
newFont = FontUIResource('Dialog',0,newFontSize)
btr.viewport.view.setFont(newFont)
btr.viewport.view.setCellRenderer(cellRenderer)

```

So one thing I learned from this is exported templates also seem to export the Component with them, and although the running production system is running Gateway v7.9.12, but the template I modified is OLD, so it is using a very old version of the Tag Browse Tree which doesn’t exhibit this behaviour.

One important thing to note is that using the

```auto
btr.viewport.view.setFont(newFont)

```

breaks the ability to set the font from the Property Editor within designer. Oh well, win some, lose some 😉

---

<div class="post-metadata">

**Author:** ![John\_S1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@John\_S1](https://forum.inductiveautomation.com/u/John_S1)\
**Post date:** [December 15, 2022, 9:02am UTC](https://forum.inductiveautomation.com/t/customizing-tag-browse-tree/28755/6 "2022-12-15T09:02:00Z")

</div>

Hello  
Is it possible that we can change the folder icon color and text color in the tag tree?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 15, 2022, 10:38am UTC](https://forum.inductiveautomation.com/t/customizing-tag-browse-tree/28755/7 "2022-12-15T10:38:05Z")

</div>

This exact same question came up a couple of days ago in this thread:

> [@How to change the background color for Tag Browse Tree component](https://forum.inductiveautomation.com/t/how-to-change-the-background-color-for-tag-browse-tree-component/66001/5):
>
> I couldn't find an intuitive way to do this, but the below approach works. This script is designed for the propertyChange event handler of the tag browse tree: if event.propertyName == 'rootNodePath': from java.awt import Color component = event.source.getTree().getCellRenderer() textNonSelectionColorField = component.getClass().getDeclaredField('textNonSelectionColor') textNonSelectionColorField.setAccessible(True) textNonSelectionColorField.set(component, Color.blue) Result: [image] …

The icon folders are actually png files, so they would have to be replaced to change the color  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/7/e798dc9e83ee193346d999f9755ae460a931ee8f.png)

---

<div class="post-metadata">

**Author:** ![John\_S1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@John\_S1](https://forum.inductiveautomation.com/u/John_S1)\
**Post date:** [December 15, 2022, 11:05am UTC](https://forum.inductiveautomation.com/t/customizing-tag-browse-tree/28755/8 "2022-12-15T11:05:19Z")

</div>

Thanks, I will check on that thread.
