# Power table changing border line color

**URL:** <https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570>\
**Category:** Ignition\
**Tags:** vision, ignition81, scripting\
**Created:** [March 3, 2023, 12:39am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570 "2023-03-03T00:39:03Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Kevin\_Dagapioso](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dan\_Kevin\_Dagapioso](https://forum.inductiveautomation.com/u/Dan_Kevin_Dagapioso)\
**Post date:** [March 3, 2023, 12:39am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/1 "2023-03-03T00:39:03Z")

</div>

I would like to ask how can change the color or the border line in a power table. Thank you!  
 ![Screenshot 2023-03-03 083835](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/f/5f6066bea4464b96a10783bcf13f8e1eb1d8e99f.png)

---

<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:** [March 3, 2023, 12:42am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/2 "2023-03-03T00:42:53Z")

</div>

Here is a tutorial I made previously in the forum that explains how to do this:

> [@Vision Power Table - Add columns border with configureEditor()](https://forum.inductiveautomation.com/t/vision-power-table-add-columns-border-with-configureeditor/67607/3):
>
> I found a few moments this morning to adapt the above suggestion into my test table. 
> 
> > **Here is the sample code:**
> >
> > def configureCell([...]): from javax.swing import BorderFactory from java.awt import Color if rowIndex == 0 and colIndex == 0: border = BorderFactory.createMatteBorder(8, 8, 1, 4, Color(255, 255, 255)) elif rowIndex == (self.data.rowCount-1) and colIndex == 0: border = BorderFactory.createMatteBorder(1, 8, 8, 4, Color(255, 255, 255)) elif rowIndex == 0 and colIndex == (self.data…

---

<div class="post-metadata">

**Author:** ![Dan\_Kevin\_Dagapioso](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dan\_Kevin\_Dagapioso](https://forum.inductiveautomation.com/u/Dan_Kevin_Dagapioso)\
**Post date:** [March 9, 2023, 2:51am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/3 "2023-03-09T02:51:56Z")

</div>

I just need the borderline not all the columns and rows

---

<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:** [March 9, 2023, 2:56am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/4 "2023-03-09T02:56:03Z")

</div>

Just the one on the left, or the whole outline?

---

<div class="post-metadata">

**Author:** ![Dan\_Kevin\_Dagapioso](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dan\_Kevin\_Dagapioso](https://forum.inductiveautomation.com/u/Dan_Kevin_Dagapioso)\
**Post date:** [March 9, 2023, 2:58am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/5 "2023-03-09T02:58:35Z")

</div>

the whole outline

---

<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:** [March 9, 2023, 3:05am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/6 "2023-03-09T03:05:28Z")

</div>

Okay, I've adapted the example code to just do a single border:

```auto
#def configureCell([...]):
	from javax.swing import BorderFactory
	from java.awt import Color
	borderColor = Color(0, 0, 0)
	if rowIndex == 0 and colIndex == 0:
		border = BorderFactory.createMatteBorder(2, 2, 0, 0, borderColor)
	elif rowIndex == (self.data.rowCount-1) and colIndex == 0:
		border = BorderFactory.createMatteBorder(0, 2, 2, 0, borderColor)
	elif rowIndex == 0 and colIndex == (self.data.columnCount-1):
		border = BorderFactory.createMatteBorder(2, 0, 0, 2, borderColor)
	elif rowIndex == (self.data.rowCount-1) and colIndex == (self.data.columnCount-1):
		border = BorderFactory.createMatteBorder(0, 0, 2, 2, borderColor)	
	elif rowIndex == (self.data.rowCount-1) and colIndex == 0:
		border = BorderFactory.createMatteBorder(0, 2, 2, 0, borderColor)
	elif rowIndex == 0:
		border = BorderFactory.createMatteBorder(2, 0, 0, 0, borderColor)
	elif rowIndex == (self.data.rowCount-1):
		border = BorderFactory.createMatteBorder(0, 0, 2, 0, borderColor)
	elif colIndex == 0:
		border = BorderFactory.createMatteBorder(0, 2, 0, 0, borderColor)
	elif colIndex == (self.data.columnCount-1):
		border = BorderFactory.createMatteBorder(0, 0, 0, 2, borderColor)
	else:
		border = BorderFactory.createMatteBorder(0, 0, 0, 0, borderColor)
	return {'border': border}

```

**Result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/d/dd256e719498806a4f84e95fd709144eb19eec66.png)

**Note:**  
for each cell: `BorderFactory.createMatteBorder(TOP, LEFT, BOTTOM, RIGHT, borderColor)`

**Edit:** Removed an `8` typo from one of the borders

---

<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:** [March 9, 2023, 3:15am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/7 "2023-03-09T03:15:48Z")

</div>

For an outline that goes around the outside of the header instead of the inside, use the configureHeaderStyle extension function in conjunction with the configureCell to produce the effect:

**Example:**  
configureHeaderStyle Script:

```auto
#def configureHeaderStyle(self, colIndex, colName):
	from javax.swing import BorderFactory
	from java.awt import Color
	borderColor = Color(0, 0, 0)
	if colIndex == 0:
		border = BorderFactory.createMatteBorder(2, 2, 0, 0, borderColor)
	elif colIndex == (self.data.columnCount-1):
		border = BorderFactory.createMatteBorder(2, 0, 0, 2, borderColor)
	else:
		border = BorderFactory.createMatteBorder(2, 0, 0, 0, borderColor)
	return {'border': border}

```

> **configureCell Script:**
>
> ```auto
> #def configureCell([...]):
> from javax.swing import BorderFactory
> from java.awt import Color
> borderColor = Color(0, 0, 0)
> if rowIndex == 0 and colIndex == 0:
> border = BorderFactory.createMatteBorder(0, 2, 0, 0, borderColor)
> elif rowIndex == (self.data.rowCount-1) and colIndex == 0:
> border = BorderFactory.createMatteBorder(0, 2, 2, 0, borderColor)
> elif rowIndex == 0 and colIndex == (self.data.columnCount-1):
> border = BorderFactory.createMatteBorder(0, 0, 0, 2, borderColor)
> elif rowIndex == (self.data.rowCount-1) and colIndex == (self.data.columnCount-1):
> border = BorderFactory.createMatteBorder(0, 0, 2, 2, borderColor)	
> elif rowIndex == (self.data.rowCount-1) and colIndex == 0:
> border = BorderFactory.createMatteBorder(0, 2, 2, 0, borderColor)
> elif rowIndex == 0:
> border = BorderFactory.createMatteBorder(0, 0, 0, 0, borderColor)
> elif rowIndex == (self.data.rowCount-1):
> border = BorderFactory.createMatteBorder(0, 0, 2, 0, borderColor)
> elif colIndex == 0:
> border = BorderFactory.createMatteBorder(0, 2, 0, 0, borderColor)
> elif colIndex == (self.data.columnCount-1):
> border = BorderFactory.createMatteBorder(0, 0, 0, 2, borderColor)
> else:
> border = BorderFactory.createMatteBorder(0, 0, 0, 0, borderColor)
> return {'border': border}
> 
> ```

**Result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/4/b4ff11e6cf5f358a21dd06af8031a29ab8388c12.png)

---

<div class="post-metadata">

**Author:** ![Dan\_Kevin\_Dagapioso](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dan\_Kevin\_Dagapioso](https://forum.inductiveautomation.com/u/Dan_Kevin_Dagapioso)\
**Post date:** [March 9, 2023, 3:29am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/8 "2023-03-09T03:29:21Z")

</div>

why is it like that? i put your code in my sample power table and just change the color.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/4/349c0a3c13b00c4e172d0b7b8b1f8b58c4c31916.png)

---

<div class="post-metadata">

**Author:** ![Dan\_Kevin\_Dagapioso](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dan\_Kevin\_Dagapioso](https://forum.inductiveautomation.com/u/Dan_Kevin_Dagapioso)\
**Post date:** [March 9, 2023, 3:44am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/9 "2023-03-09T03:44:12Z")

</div>

The white border still showing and also not the outside border change. I want to change the white outside border color.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/4/5433297b1bffa0bc3dad3206483b45103725bbd0.png)

---

<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:** [March 9, 2023, 3:54am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/10 "2023-03-09T03:54:15Z")

</div>

I see what you mean. I set my background to black and set my border to blue, and I am able to replicate the problem, but only when the app doesn't have focus.

**With Focus:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/4/0473e1a4cd22ce7ecd8700431fe9954647032185.png)

**Without Focus:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/9/f9ded5e9f016ecb82952ab2ada72c286a31b6cfe.png)

I'm not sure what's causing that, but if I figure something out, I will post it here.

---

<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:** [March 9, 2023, 3:58am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/11 "2023-03-09T03:58:44Z")

</div>

Making the background transparent didn't fix it. It looked like it had worked, but clicking around, the unwanted outline reappeared

---

<div class="post-metadata">

**Author:** ![Dan\_Kevin\_Dagapioso](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dan\_Kevin\_Dagapioso](https://forum.inductiveautomation.com/u/Dan_Kevin_Dagapioso)\
**Post date:** [March 9, 2023, 4:07am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/12 "2023-03-09T04:07:01Z")

</div>

i see. if you figure something out just post it here. Thanks btw for helping me! much appreciated.

---

<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:** [March 9, 2023, 4:49am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/13 "2023-03-09T04:49:16Z")

</div>

This line of code fixes the problem:  
`self.setBorder(None)`

The table comes with a `javax.swing.plaf.synth.SynthBorder` that causes the observed effect. The above code simply removes it from the table.

In testing, I disabled the border code in the two extension functions, and then set the border directly from a button using the following code:

```auto
component = event.source.parent.getComponent('Power Table')
from javax.swing import BorderFactory
from java.awt import Color
border = BorderFactory.createLineBorder(Color.red)
component.setBorder(border)

```

**This was the result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/0/d0debd52efa4d35a6e2a3f59e9b052e7d190d12c.png)

This should work from the table's _initialize_ extension function by changing the the first line to `component = self`, but that extension function won't fire from the designer, so an actual session will be needed to test it.

**Edit:** Noticed the `Color` import was somehow missing from the script

---

<div class="post-metadata">

**Author:** ![Dan\_Kevin\_Dagapioso](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dan\_Kevin\_Dagapioso](https://forum.inductiveautomation.com/u/Dan_Kevin_Dagapioso)\
**Post date:** [March 10, 2023, 5:12am UTC](https://forum.inductiveautomation.com/t/power-table-changing-border-line-color/70570/14 "2023-03-10T05:12:15Z")

</div>

thank you!! this works for me!
