# Change the header color of a Alarm Status Table

**URL:** <https://forum.inductiveautomation.com/t/change-the-header-color-of-a-alarm-status-table/41933>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [January 4, 2021, 5:01pm UTC](https://forum.inductiveautomation.com/t/change-the-header-color-of-a-alarm-status-table/41933 "2021-01-04T17:01:51Z")\
**Posts on this page:** 1\
**Showing post:** 13

<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 20, 2022, 7:20pm UTC](https://forum.inductiveautomation.com/t/change-the-header-color-of-a-alarm-status-table/41933/13 "2022-12-20T19:20:08Z")

</div>

Today, I developed a dark mode for the alarm status table, and indeed, the header was a bit tricky. The top right corner can be set directly, but to change the header itself, I ended up setting it's background to transparent, so the underlying color could come through. The top left corner underneath the multistate button is a buffered image, so I ended up having to create a graphic to paint over it.  
**Here is the result:**

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

Here is the full code for dark mode in a version that was set up on the actionPerformed event handler of a test button located in the same container as the table:

> **Original Source Code**
>
> ```auto
> from java.awt import Color
> 
> #Sets Footer Color
> event.source.parent.getComponent('Alarm Status Table').getComponent(0).background = Color(57,56,61)
> 
> #Colors the divider at the right side of the footer
> event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(1).getComponent(1).background = Color(57,56,61)
> 
> #Acknowledge Button Color
> event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(1).getComponent(0).getComponent(0).background = Color(57,56,61)
> 
> #Shelve Button Color
> event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(1).getComponent(0).getComponent(1).background = Color(57,56,61)
> 
> #Colors the gridlines and any uncovered background for the table
> event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(0).getComponent(0).background = Color(57,56,61)
> 
> # Allows header to inherit the background color of the underlying panel
> event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(0).getComponent(0).getTableHeader().setOpaque(False)
> 
> #Sets the font color of the header row
> event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(0).getComponent(0).getTableHeader().setForeground(Color(248,248,248))
> 
> #Sets the background color for the header
> event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(5).getComponent(0).background = Color(57,56,61)
> 
> #Colors the alarm selection buttons
> event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(3).getComponent(0).background = Color(57,56,61)
> 
> #Colors the multiselect button itself in the top left corner
> event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(4).getComponent(0).background = Color(57,56,61)
> 
> #Colors the top right corner
> event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0).background = Color(57,56,61)		
> 
> #Paints the corner behind the multiselect box in the top left of the table
> corner = event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(4)
> corner_Field = corner.getClass().getDeclaredField('corner')
> corner_Field.setAccessible(True)
> corner_Value = corner_Field.get(corner)
> graphics = corner_Value.createGraphics()
> graphics.setPaint(Color(57,56,61))
> graphics.fillRect (0, 0, corner_Value.getWidth(), corner_Value.getHeight())
> 
> ```

**Edit:** Encountered a scenario where the original source code didn't work due to a variation in the way the table was structured that resulted in a "No Child 5" error  
Here is a generic version that should work no matter how the table is structured:

> **Revised Source Code**
>
> ```auto
> def setDarkMode(alarmStatusTable):
> from java.awt import Color
> if alarmStatusTable.componentCount > 0:
> for component in alarmStatusTable.getComponents():
> try:
> component.foreground = Color(248,248,248)
> except:
> pass
> try:
> component.background = Color(57,56,61)
> except:
> pass
> try:
> component.getTableHeader().setOpaque(False)
> component.getTableHeader().setForeground(Color(248,248,248))
> except:
> pass
> try:
> corner = component
> corner_Field = corner.getClass().getDeclaredField('corner')
> corner_Field.setAccessible(True)
> corner_Value = corner_Field.get(corner)
> graphics = corner_Value.createGraphics()
> graphics.setPaint(Color(57,56,61))
> graphics.fillRect (0, 0, corner_Value.getWidth(), corner_Value.getHeight())
> except:
> pass
> setDarkMode(component)
> alarmStatusTable = event.source.parent.getComponent('Alarm Status Table')
> setDarkMode(alarmStatusTable)
> 
> ```

---

_[View the full topic](https://forum.inductiveautomation.com/t/change-the-header-color-of-a-alarm-status-table/41933)._
