• 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

JPanel not always opaque by default ...

 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

when running some tests on my linux box (RHEL) the last couple of days I had trouble setting background colors of a simple JPanel. The colors did show up correctly running the crossplatform look on feel (javax.swing.plaf.metal.MetalLookAndFeel). The colors did NOT show up correctly running the system look and feel (com.sun.java.swing.plaf.gtk.GTKLookAndFeel).
After some troubleshooting I finally did a simple test to check the opaque property of a JPanel (full sourcecode below). The results were disturbing to me: using MetalLookAndFeel a JPanel is created opaque by default, using the GTKLookAndFeel a JPanel is NOT opaque by default ??!! Obviously this has some undesired effects for colors showing up or not.
Does anyone know why the opaqueness of a panel would need to be different under different look and feels ?
Anyone else observed this behaviour ?
Bottom line, if you want to make sure colors show up correctly, always set the opaque property even when you think it is not neccessary...

Regards, Ronald.

Here is the test source code, note the comments and run under linux/winxp to see the differences.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm moving this to our Swing forum because I think you will get a response there.
 
reply
    Bookmark Topic Watch Topic
  • New Topic