Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Problem repainting overlapping JPanels

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have added a JPanel to a JPanel. The JPanel 'on top' has a tooltip.
If the tooltip is displayed such that the tooltip window is completely within the bounds of the 'upper' JPanel, the area occupied by the tooltip window is not repainted when the tooltip disapears. Can anybody explain why?

The code below demonstrates the problem.

If you run the code: display the tooltip over the grey JPanel. If the tooltip window does not overlap the white JPanel, the repainting
does not occur. If the tooltip touches the white JPanel everything is
ok.



Rich
[ July 18, 2004: Message edited by: Rich Smyth ]
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Transparent background colors don't tend to work. The JComponent javadocs specify that an opaque component must paint every pixel within its bounds in a non-transparent color. This is a reasonable definition of opaque because it allows less painting when components overlap, but it won't work in this scenario.

To handle the transparency, you might be able to get away with something like this:


[ July 18, 2004: Message edited by: David Weitzman ]
 
Rich Smyth
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,

Thank you for the lucid explanation. Your recommendation does the trick.
BTW, in the overriding paintComponent() method I'm sure you meant
super.paintComponent(), not super.paint().

thanks again,

Rich
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic