• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Partially transparent backgrounds ?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have a gui with a picture as background, and transparent labels. I want to set the background of the labels so that they are only partially transparent, so that my background is less obtrusive where I have text.

As far as I can see a label can either be opaque or transparent and not some inbetween value.

I tried using a gif which was partially transparent as background for the label and setting opaque to false, but that didn't work

Does anyone else know how, or have any suggestions

Thanx
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to try

label.setOpaque(true);
label.setBackground(new Color(redComponent, greenComponent, blueComponent, 30));

Where 30 is just an arbitrary alpha value from 0-255 setting the transparency (0 is invisible, 255 is opaque). However when I tried it (two partially transparent backgrounds for JLabels in a JLayeredPane) the background was actually changing color after repaints...so...hmmm. Maybe it'll work for you?

The first alternative which comes into my mind is this:

 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic