This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTable background colour, semi-transparent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable background colour, semi-transparent" Watch "JTable background colour, semi-transparent" New topic
Author

JTable background colour, semi-transparent

Harold Lime
Ranch Hand

Joined: Jul 20, 2009
Posts: 38
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

Joined: Aug 25, 2009
Posts: 20
I think you need to set the JTable opacity
table.setOpaque(true);
Or set the component opacity, I forget.

Harold Lime
Ranch Hand

Joined: Jul 20, 2009
Posts: 38
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

Joined: Oct 27, 2005
Posts: 19723
    
  20

Opaque means it's not transparent, so by calling setOpaque(false), you're turning off the not-being-transparent.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Harold Lime
Ranch Hand

Joined: Jul 20, 2009
Posts: 38
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

Joined: Jun 13, 2009
Posts: 2204
    
    7
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

Joined: Jul 20, 2009
Posts: 38
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable background colour, semi-transparent