# JProgressBar.foreground doesn't work like in Ignition 7

**URL:** <https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [December 20, 2019, 6:51pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874 "2019-12-20T18:51:29Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![informatica](https://avatars.discourse-cdn.com/v4/letter/i/3ab097/32.png) [@informatica](https://forum.inductiveautomation.com/u/informatica)\
**Post date:** [December 20, 2019, 6:51pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/1 "2019-12-20T18:51:29Z")

</div>

Good afternoon.

In Ignition **7.9.9** , in a “PowerTable”, you can use “ **JProgressBar** ” class to draw a progress bar in a cell.  
The “ **foreground** ” property is the **color of the progress bar** :

- Ignition 7 ( **Power Table** ):  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/7b34b276b3e15b0d261b6e2cdbf68dabf64c208b.png)

- Ignition 7 ( **configureCell event** ):  

In Ignition **8.0.6** , in a “PowerTable”, also you can use “ **JProgressBar** ” class to draw a progress bar in a cell, but the “ **foreground** ” property is the **color of the font** :

- Ignition 8 ( **Power Table** ):

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/3e8a7e2eb641ded51c64bd96dfe0d45b0e4c0b4b.png)

- Ignition 8 ( **configureCell event** ), the same code:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/31dfc064a2fa7ce83ade0af3437fa31c91098db5.png)

So how can I set the color of the progress bar?

Best Regards.

---

<div class="post-metadata">

**Author:** ![informatica](https://avatars.discourse-cdn.com/v4/letter/i/3ab097/32.png) [@informatica](https://forum.inductiveautomation.com/u/informatica)\
**Post date:** [March 11, 2020, 2:23pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/2 "2020-03-11T14:23:58Z")

</div>

Good afternoon.

Any help?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 11, 2020, 2:53pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/3 "2020-03-11T14:53:06Z")

</div>

See if any of these properties work. It seems there are some progress bar related properties: [http://www.javasoft.de/synthetica/customize/](http://www.javasoft.de/synthetica/customize/)

---

<div class="post-metadata">

**Author:** ![informatica](https://avatars.discourse-cdn.com/v4/letter/i/3ab097/32.png) [@informatica](https://forum.inductiveautomation.com/u/informatica)\
**Post date:** [March 11, 2020, 7:28pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/4 "2020-03-11T19:28:17Z")

</div>

It does not work.

---

<div class="post-metadata">

**Author:** ![ricardo.ortolani](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@ricardo.ortolani](https://forum.inductiveautomation.com/u/ricardo.ortolani)\
**Post date:** [October 11, 2021, 2:51pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/5 "2021-10-11T14:51:24Z")

</div>

Any update on this, I have the same problem with Ignition 8, where it change the color of the text not the progress bar ☹

---

<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 11, 2021, 4:07pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/6 "2021-10-11T16:07:42Z")

</div>

What version are you on? In 8.1.6 we updated the look and feel, so while the ‘foreground color’ property controls the appearance of the progress bar, there’s a separate text property color available.

---

<div class="post-metadata">

**Author:** ![ricardo.ortolani](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@ricardo.ortolani](https://forum.inductiveautomation.com/u/ricardo.ortolani)\
**Post date:** [February 1, 2022, 7:57pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/7 "2022-02-01T19:57:38Z")

</div>

Hello @paul-griffith, I am using 8.1.11 and I am running into the same issue

foreground and background changes the colors of the progress bar

So what is the property that is use for the text in order to change the color?

thanks

---

<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:** [February 1, 2022, 9:53pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/8 "2022-02-01T21:53:22Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0e52819bd65578a67701f11417b295b70e4b1dd8.png)  
The text color property.

---

<div class="post-metadata">

**Author:** ![ricardo.ortolani](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@ricardo.ortolani](https://forum.inductiveautomation.com/u/ricardo.ortolani)\
**Post date:** [February 1, 2022, 10:32pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/9 "2022-02-01T22:32:04Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/1/f100f64538d3663d5a11b0e0880597204c0e619c.png)

My power table does not have that option and I am on version 8.1.11 (b2021101912), do I need to check something to show that option?

---

<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:** [February 1, 2022, 10:55pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/10 "2022-02-01T22:55:10Z")

</div>

Oh, my bad, I didn’t read the topic fully. Let me look into how you’d do this, I’m pretty sure it’s possible.

@ricardo.ortolani are you creating your own JProgressBar in `configureCell` like @informatica is?

If so, you can `putClientProperty("Synthetica.progressBar.textColor", textColor)` in that script and the color you select should be respected.

---

<div class="post-metadata">

**Author:** ![Matthew.gaitan](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Matthew.gaitan](https://forum.inductiveautomation.com/u/Matthew.gaitan)\
**Post date:** [February 1, 2022, 10:57pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/11 "2022-02-01T22:57:23Z")

</div>

For the power table, you need to do something like the following:

add this code to the `initialize` function of your power table

```auto
	from javax.swing import JProgressBar, UIManager
	from java.awt import Color, Font
	
	self.putClientProperty("JProgressBar", JProgressBar)
	self.putClientProperty("UIManager", UIManager)
	self.putClientProperty("Color", Color)
	self.putClientProperty("Font", Font)	

```

In `configureCell` you need to use code to change the textColor depending on whatever criteria you want:

```auto
	JProgressBar = self.getClientProperty("JProgressBar")
	UIManager = self.getClientProperty("UIManager")
	Color = self.getClientProperty("Color")
	Font = self.getClientProperty("Font")

	if colIndex == 1:
		pb = JProgressBar(0, 100)
	
		pb.foreground = Color.ORANGE
		
		if value < 30:
			UIManager.put("Synthetica.progressBar.textColor", Color.RED);
		elif value < 70:
			UIManager.put("Synthetica.progressBar.textColor", Color.YELLOW);
		else:
			UIManager.put("Synthetica.progressBar.textColor", Color.GREEN);
		pb.setValue(value)
		
		pb.setString(str(value))
		
		pb.setStringPainted(True)
		
		pb.setFont(Font("Dialog", 1, 12))
		
		return {'renderer': pb}

```

result:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/f/8fdc35bd3b2a579f898d30e55db9c06ce5dd63a6.png)

---

<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:** [February 1, 2022, 11:01pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/12 "2022-02-01T23:01:40Z")

</div>

You shouldn’t need to go through UIManager for this. Something like this entirely in `configureCell` should work:

```python
	from javax.swing import JProgressBar
	from java.awt import Color

	def setTextColor(bar, color):
		bar.putClientProperty("Synthetica.progressBar.textColor", color)

	if colIndex == 1:
		pb = JProgressBar(0, 100)
		pb.foreground = Color.ORANGE
		
		if value < 30:
			setTextColor(pb, Color.RED)
		elif value < 70:
			setTextColor(pb, Color.YELLOW)
		else:
			setTextColor(pb, Color.GREEN)
		pb.value = value
		pb.string = str(value)
		pb.stringPainted = True
		pb.font = Font("Dialog", 1, 12)
		
		return {'renderer': pb}

```

For efficiency, you can cache the JProgressBar you create in client props, but it’s probably not necessary.

---

<div class="post-metadata">

**Author:** ![Matthew.gaitan](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Matthew.gaitan](https://forum.inductiveautomation.com/u/Matthew.gaitan)\
**Post date:** [February 1, 2022, 11:04pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/13 "2022-02-01T23:04:54Z")

</div>

> [@paul-griffith](#):
>
> ```auto
> bar.putClientProperty("Synthetica.progressBar.textColor", color)
> 
> ```

Interesting! I didn't realize you could do this directly without UIManager

---

<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:** [February 1, 2022, 11:09pm UTC](https://forum.inductiveautomation.com/t/jprogressbar-foreground-doesnt-work-like-in-ignition-7/30874/14 "2022-02-01T23:09:41Z")

</div>

There’s no strict conventions for styling components in Swing. Every look and feel does things somewhat differently once you get into the nitty gritty; usually UIManager keys cover defaults and high-level operations, but client properties are common for overriding individual component values.
