I set the background of a JWindow completely transparent. Then I painted a rounded Rectangle (RGB: 0,0,0,100) in it's paint-Method and added a JLabel to the JWindows ContentPane. But when I try to repaint the JWindow to update the JLabel, it doesn't remove the old Rectangle and the old value of the JLabel. So the result is that my custom tooltip box (what it should be) gets less transparent and you cannot read the JLabels contents, because it overlays the old contens.

Is there any way to solve this problem?

BTW, if I don't repaint, it doesn't get less transparent, but the new contents of my JLabel overlays the old Contents, like it is, when I repaint.

1 Answer
1

First you should override paintComponent instead of paint and call super.paintComponent(g). You should leave JWindow opaque, because the component on the rearmost layer will clear the old contents. If all the layers are transparent you will end up with screen garbage.

Yes, I want to create translucent windows, but I think it doesn't work for Mac OS 10.6.6.
–
esanitsMar 8 '11 at 10:45

JWindow doesn't have paintComponent(Graphics g) but it has paintComponents(Graphics g). But when I override it it doesn't paint anything?
–
esanitsMar 8 '11 at 11:25

I think the content pane is a JPanel, so you can set the content paint to your own custom JPanel and override paintComponent(). The question 'How can I create translucent windows on Mac OS?' is definitely worth asking IMO.
–
z7sg ѪMar 8 '11 at 11:31