# Tree View Expansion

**URL:** <https://forum.inductiveautomation.com/t/tree-view-expansion/2596>\
**Category:** Ignition\
**Created:** [February 1, 2011, 9:29pm UTC](https://forum.inductiveautomation.com/t/tree-view-expansion/2596 "2011-02-01T21:29:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![f\_jons](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@f\_jons](https://forum.inductiveautomation.com/u/f_jons)\
**Post date:** [February 1, 2011, 9:29pm UTC](https://forum.inductiveautomation.com/t/tree-view-expansion/2596/1 "2011-02-01T21:29:42Z")

</div>

Is there any way to make the plus sign to expand a tree view node larger?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 1, 2011, 10:11pm UTC](https://forum.inductiveautomation.com/t/tree-view-expansion/2596/2 "2011-02-01T22:11:33Z")

</div>

Sure, you can use the following as your project’s Client Startup script:

[code]from javax.swing import Icon

class TreeIcon(Icon):  
def **init** (self,plus,size=18):  
self.plus=plus  
self.size=size

```
def paintIcon(self, comp, g, x, y):
	from java.awt import Color
	s = self.size
	half = s/2

	g.setColor(Color.WHITE)
	g.fillRect(x,y,s,s)
	g.setColor(Color.GRAY)
	g.drawRect(x,y,s,s)
	g.setColor(Color.BLACK)
	g.drawLine(x+3,y+half,x+s-3,y+half)
	if self.plus:
		g.drawLine(x+half,y+3,x+half,y+s-3)

def getIconWidth(self):
	return self.size
def getIconHeight(self):
	return self.size

```

from javax.swing import UIManager  
UIManager.put(“Tree.expandedIcon”, TreeIcon(0,16))  
UIManager.put(“Tree.collapsedIcon”, TreeIcon(1,16))[/code]

You can play with the sizing by adjusting the 2nd parameter to the TreeIcon’s constructor. (the last two lines of the script)

![](https://us1.discourse-cdn.com/inductiveautomation/original/1X/fc8faf950c6037cc65c6038421da101643c5ab69.PNG)

Ok, I’ll admit it - I had fun with this one 😆 Don’t worry if this looks bizarre to you - this is one of those “pay no attention to the man behind the curtain” moments.

Hope this helps,

---

<div class="post-metadata">

**Author:** ![f\_jons](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@f\_jons](https://forum.inductiveautomation.com/u/f_jons)\
**Post date:** [February 2, 2011, 4:52am UTC](https://forum.inductiveautomation.com/t/tree-view-expansion/2596/3 "2011-02-02T04:52:07Z")

</div>

Works perfectly, and after looking at it, I realized that you are just creating your own Icons. (Which means, I could get creative with modifying the colors, etc. Clever. Fits in with all the other clever things this program is doing.

Thanks!

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 2, 2011, 11:11pm UTC](https://forum.inductiveautomation.com/t/tree-view-expansion/2596/4 "2011-02-02T23:11:57Z")

</div>

Thats right - Ignition is based on Java Swing, which has whats called a pluggable look-and-feel (PLAF) system. You can use the UIManager to tweak lots of things about the UI - default colors, sizes, icons, fonts, etc.

Combine this with Jython’s ability to create classes that subclass from Java classes and voilà - you can implement your own custom icons for Swing’s benefit.

---

<div class="post-metadata">

**Author:** ![f\_jons](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@f\_jons](https://forum.inductiveautomation.com/u/f_jons)\
**Post date:** [February 3, 2011, 2:31am UTC](https://forum.inductiveautomation.com/t/tree-view-expansion/2596/5 "2011-02-03T02:31:10Z")

</div>

Do you have/know of any good guide for the PLAF aspect of Swing?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 3, 2011, 5:04pm UTC](https://forum.inductiveautomation.com/t/tree-view-expansion/2596/6 "2011-02-03T17:04:36Z")

</div>

The PLAF system itself is fairly well documented (google search should find some things) but to be honest thats probably too far-reaching for the kind of stuff most people want to do.

I find that manipulating the values in UIManager is a very handy thing to do, and for whatever reason, this aspect is poorly documented. I’ve attached an excel spreadsheet that I created a long time ago that I refer to whenever I need to mess around with this system. Maybe you’ll find it helpful. Note that when the value is something incomprehensible you should probably leave it alone. On a broader note - you’re playing with fire a bit here, so don’t be too shocked if you mess something up. You should be able to just remove that part of your script and restart the client and you’ll be fine.  
[UIManager.xls](https://us1.discourse-cdn.com/inductiveautomation/original/1X/fe46e540615906010e063c6e8367e0d1c1d66960.xls) (99 KB)

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [February 3, 2011, 7:57pm UTC](https://forum.inductiveautomation.com/t/tree-view-expansion/2596/7 "2011-02-03T19:57:34Z")

</div>

> [@Carl.Gould](#):
>
> Thats right - Ignition is based on Java Swing, which has whats called a pluggable look-and-feel (PLAF) system.

Can I drop in the [napkin](http://napkinlaf.sourceforge.net/) look and feel. 😈

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 3, 2011, 9:11pm UTC](https://forum.inductiveautomation.com/t/tree-view-expansion/2596/8 "2011-02-03T21:11:40Z")

</div>

No, if you change the whole LAF some things will break that expect the LAF that we ship with, sorry. Although I admit it would be fun 🙂

---

<div class="post-metadata">

**Author:** ![f\_jons](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@f\_jons](https://forum.inductiveautomation.com/u/f_jons)\
**Post date:** [February 4, 2011, 2:30pm UTC](https://forum.inductiveautomation.com/t/tree-view-expansion/2596/9 "2011-02-04T14:30:05Z")

</div>

Thanks for the spreadsheet Carl, that should help!

---

<div class="post-metadata">

**Author:** ![raymond1982](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/raymond1982/32/6490_2.png) [@raymond1982](https://forum.inductiveautomation.com/u/raymond1982)\
**Post date:** [September 5, 2018, 5:40pm UTC](https://forum.inductiveautomation.com/t/tree-view-expansion/2596/10 "2018-09-05T17:40:20Z")

</div>

Please repost this doc. I have recently lost it 😱
