Make a Power Table transparent, or set its background to be an image

Basically what I am trying to achieve is to have an image behind a Power Table. The Power Table will have text in each cell. When you click on a cell the cell background color will be semi-transparent. Any cell that you haven’t clicked on will have a completely transparent background. The end result being that you can see the image behind the Power Table. I have the Power Table background to 255,200,200,50 (tried 255,200,200,0 as well). I have also tried the following initialization script on the Power Table (you can see I am trying several approaches):

from java.awt import Color
from java.lang import Object
from javax.swing.table import DefaultTableCellRenderer
self.setOpaque(False)
self.setBackground(Color(255, 200, 200, 50))
self.getTable().getDefaultRenderer(Object).setOpaque(False)
self.getTable().getDefaultRenderer(Object).setBackground(Color(255, 200, 200, 50))
renderer = DefaultTableCellRenderer()
renderer.setOpaque(False)
renderer.setBackground(Color(255, 200, 200, 50))
self.getTable().getColumn('Int Column').setCellRenderer(renderer)

Trying all these things, I cannot see behind the Power Table.

Any ideas? Thanks!

1 Like

So, I figured out how to make the PowerTable transparent. You have to make three things transparent, two of which are obvious, one of which isn’t.

  • Make Power Table transparent by setting background property alpha value to 0. Such as 255,255,255,0. This can be done in the property editor.
  • Make each cell transparent via the configureCell extension function. Such as:
from java.awt import Color
return {'background': Color(255, 255, 255, 0)}
  • Set the Viewport transparent, via the initialize script, such as:
from java.awt import Color
self.setOpaque(False)
self.getTable().getParent().setBackground(Color(255, 255, 255, 0))	
self.getTable().setOpaque(False)

This item also sets the opaque property to False on the JideTable and the Power Table.

6 Likes

There is still the issue of some funny business going on, with different areas of the screen being drawn behind the table when you click on cells. Calling repaint() on the power table clears these up but I’m currently figuring out when to call this automatically.

1 Like

Did you find a solution for this funny business? Struggling with the same issue now…

hello, I have the same issue. I don’t kown how to call the repaint function, could you write some example on it? thank you very much!

I believe you can call repaint() on any component. Like if you are writing a method on the component, you would just write self.repaint()