Alarm status table background color doesn't change

I'm trying to change my Alarm Status Table's background color on Vision, but when I select a color on the Appearance->Table Background property it just changes the selector's background.

image

Could someone help with it?

This works for me for changing the table's background. For example, when I set it to black, it looks like this:

What specific part of the table are you wanting to change?

1 Like

I want the exactly part you've got black, but when I try it just changes the left part, where we can select each row using the checkboxes.

Is it because the number of rows you have fills the whole table?

1 Like

No, I didnt. During my tests, there were just 3-5 alarms on table

I'm not sure. I have done a complete dark mode tutorial for the alarm status table before, although it's kind of off topic in the thread it's in.

Here's the link to it. Perhaps there will be something buried in there that will help you get the result you are after:

One bad thing about using a dark background color on a Vision table with checkboxes is that they become hard to see. I've also done an alarm status table tutorial on how to customize the checkboxes. Perhaps that will help you out as well:
Alarm table checkbox size

Psst! Don't use dark mode! At least, don't force anyone to use it. It increases eyestrain, a problem for all but the youngest of users.

2 Likes

For me, the background changes only if I set 'Marquee Mode' to ON... :confused:
AlarmStatusTableBackground

1 Like

There must be something additional because I still can't replicate this behavior with either marquee mode setting. My test environment is currently 8.1.20, so I'm overdue for an upgrade. Do you know if the table has always been this way, or was this behavior just recently noticed?

Edit: I just upgraded to 8.1.35, and that made the difference. The full background no longer changes color unless Marquee Mode is true.

Looking for a work around, [Other than simply using the marquee mode], :rofl: I dug around in the component when the marquee mode was False, and found that the JideScrollPane provides the background color for the missing segment.
Here is a script I developed that fills in the missing background from a test button:

# This function recursively finds the JideScrollPane
# ...and sets its background to match the tableBackground
def setTableBackground(table):
	for component in table.getComponents():
		if component.__class__.__name__ == 'JideScrollPane':
			component.background = statusTable.tableBackground
			break
		setTableBackground(component)

# Get the status table
statusTable = event.source.parent.getComponent('Alarm Status Table')

# Fill in the missing the background color using the setTableBackground function
setTableBackground(statusTable)

I tried to do this from a listener that would be applied to the scroll pane at initialization, but the listener doesn't survive any marquee mode change or any subsequent background color change, so the scroll pane must be replaced during these events.

Also, I found that changing the tableBackground and marqueeMode propertyChange event does NOT produce an event in the propertyChange event handler, so those properties can't be used to automatically fill in the missing color during property changes.

2 Likes

Update: This morning, I took another look at this, and this time, I added a container listener to the jpanel that holds the JideScrollPane. Whenever the component switches to Marquee mode, the JideScrollPane is replaced with a MarqueePane, and visa versa. While this is not surprising, what did surprise me was that any time the table background color was changed, the JideScrollPane was removed and added again. My guess is that in a recent version, the JideScrollPane lost something that allowed it to color match the table.

In any case, this initialization script will put a container listener on the pane's parent jpanel that will automatically match the JideScrollPane's color to the table background at initialization and any time the marquee mode or table background properties are subsequently changed:

# Written for the Alarm Status Table's propertyChange event handler.
# Note: 'componentRunning' fires only once when the component is first initialized
# ...and will only fire in the designer if preview mode is running
# ...BEFORE the window containing this component is opened
if event.propertyName == 'componentRunning':
	from java.awt.event import ContainerListener
	
	# This custom container listener matches the jideScrollPane background
	# ...to the table background at initialization and any time a JideScrollPane is added
	# A JideScroll Pane is added whenever the marquee mode is set to False
	# ...or when the table background is changed whild NOT in marquee mode
	class ComponentSwapListener(ContainerListener):
		def __init__(self, jpanel):
			self.setBG(jpanel)
			
		def componentAdded(self, event):
			self.setBG(event.source)
			
		def componentRemoved(self, event):
			pass
		
		def setBG(self, jpanel):
			#pane = jpanel.getComponent(0)
			#...but just in case:
			for pane in jpanel.getComponents():
				if pane.__class__.__name__ == 'JideScrollPane':
					pane.background = statusTable.tableBackground
					break
	
	# This function locates the jpanel that contains either the JideScrollPane or the MarqueePane
	# ...and adds a listener to detect a JideScrollPane being added
	def setListener(statusTable):
		for component in statusTable.getComponents():
			if component.__class__.__name__ in ['JideScrollPane', 'MarqueePane']:
				listener = ComponentSwapListener(component.parent)
				component.parent.addContainerListener(listener)
				break
			setListener(component)
	
	# Assign the status table to a variable for use by the listener
	# ...and call the setListener function
	statusTable = event.source
	setListener(statusTable)

Result:

4 Likes

Thank you, @justinedwards.jle. Your script worked like a charm. I just upgraded to 8.1.35, had the same issue, and was beginning to question whether the background colour had ever been different - good to know I wasn't imagining things!

1 Like