• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTable background colour, semi-transparent

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic