Re: Transparent JDesktopPane
- From: Luke Webber <luke@xxxxxxxxxxxxx>
- Date: Fri, 30 Jun 2006 03:32:29 GMT
Oliver Wong wrote:
[program snipped]
It looks like a bug in the paint() method of javax.swing.JLayeredPane. Basically, the code as written seems to assume that the background colour is not translucent at all, and so when it needs to "repaint" an area, it simply gets its own background colour, and paints it over the area that needs to be updated.
What's happening in your program is that when you move your JInternalFrame, there's now an old ghost-image of the JInternalFrame that needs to be painted over. If you had used a fully opaque colour like (0,0,0,255) [which is black), then the paint method would paint black pixels over the ghost image, and you'd get a completely black background.
Unfortunately, you're using the colour (0,0,0,32) which is a translucent black, so the ghost image is still visible undernearth the tranluscent black paint.
You might want to file a bug report with Sun, including your demonstration program, but I'm not sure if Sun will fix it, or just say that's the way it was designed to work.
In the meantime, you might fix it by having it so that whenever the JDesktopPane needs to repaint itself, it triggers a call to the JPanel pnlMain underneath it to paint first. So what will happen is that the pnlMain will overwrite the ghost image with red paint, and then the JDesktopPane will apply its translucent black paint over the newly applied red paint.
Thanks for that, Oliver. Looking more closely at the source code for JDesktopPane, I see that isOpaque is set to always return true. It looks as if they've decided to specifically bar the programmer from making these babies transparent, but forgot about the alpha channel possibilities. For now, I'm getting around it by ditching the whole JDesktopPane and just using JPanel derivatives. It works, but I would have liked to have it the other way.
Thanks again,
Luke
.
- References:
- Transparent JDesktopPane
- From: Luke Webber
- Re: Transparent JDesktopPane
- From: Oliver Wong
- Transparent JDesktopPane
- Prev by Date: JCheckbox in a JTable
- Next by Date: Re: AbstractAction
- Previous by thread: Re: Transparent JDesktopPane
- Next by thread: GridBagBlues #2376234
- Index(es):
Relevant Pages
|