• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable background colour, semi-transparent

 
Harold Lime
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Little help?

I'd like to show a JTable with a semi-transparent black background (I want an image underneath to be visible but still have a dark background so the text is clear), so far I've got the following code.



It works perfectly, except that when one clicks anywhere on the table the black background keeps getting darker.

I've tried disabling the JTable:



But that doesn't help, I'm not even sure why any code is executing when I click on the table - any info on that would also be appreciated.
 
David Kilcy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to set the JTable opacity
table.setOpaque(true);
Or set the component opacity, I forget.

 
Harold Lime
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Kilcy wrote:I think you need to set the JTable opacity
table.setOpaque(true);
Or set the component opacity, I forget.



setOpaque(true); - Doesn't work.

setOpaque(false); - Does work, absolutely no idea why, but thanks!
 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Opaque means it's not transparent, so by calling setOpaque(false), you're turning off the not-being-transparent.
 
Harold Lime
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:Opaque means it's not transparent, so by calling setOpaque(false), you're turning off the not-being-transparent.


I get that, it's just a bit confusing - by setting the background to a semi-transparent colour I can see through it despite me setting the opacity to false.

Edit: Scratch that, it does make sense - opacity false = transparency true.
 
Rob Camick
Ranch Hand
Posts: 2599
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Backgrounds With Transparency may help explain whats going on. Although its a little more complicated with a JTable since you also have to deal with renderers.
 
Harold Lime
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:Backgrounds With Transparency may help explain whats going on. Although its a little more complicated with a JTable since you also have to deal with renderers.


Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic