Hi Cliff,
here's a response from Swing's team Scott Violet (he was unable to
post the response on the list for some reason):
Hi Cliff.
The problem lies with setting the background color to a transparent
color. JComponent offers two very closely related properties: opaque
and background. The opaque property is used an optimization in
Swing's painting infrastructure to know where painting needs to
originate from. If opaque is true, a JComponent must fill in it's
background in an opaque color, otherwise painting artifacts will
result. The reason your code isn't working is because the content
pane of the internal frame inherits the background color of the
internal frame, a translucent color in your case, but the content
panes opaque property is true. So, to get this code to work invoke
getContentPane().setOpaque(false) and no artifacts will result:)
Additionally you don't need to set the background color to translucent
here, if opaque is false JComponent's generally don't fill in their
background.
Thank you,
Dmitri
On Sun, Aug 15, 2004 at 02:25:32AM -0400, Clifford Lyon wrote:
> Thanks. I realized what makes the JInternalFrame see through in the sample
> is actually the setBackground call. The setOpaque() on the JInternalFrame
> doesn't allow you to see the image layered behind - its as if setOpaque was
> never called.
>
> So, that's why the example isn't working. For now, I've gone to a JPanel
> with a "Close" button on it - that seems to work fine. But I'd be
> interested in hearing about how to do a transparent JInternalFrame - and
> more, about doing a JInternalFrame with an alpha < 1 (255) for the
> background color.
>
> Thanks.
>
> From: "Dmitri Trembovetski" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, August 14, 2004 6:52 PM
> Subject: Re: [JAVA2D] Transparent internal frames
>
>
> > As long as we're here, you might want to find interesting
> > Chet's recent blog:
> > http://weblogs.java.net/pub/wlg/1739
> > It's not directly relevant to your question, but anyway.
> >
> > I've also forwarded your question (with the sample code) to the
> > swing team.
> >
> > Thank you,
> > Dmitri
> >
> > On Fri, Aug 13, 2004 at 10:27:39PM -0400, Clifford Lyon wrote:
> > > Hi Dmitri, I have read and enjoyed the first article very much, but
> hadn't seen the second one - thanks very much for the pointer, it looks
> really interesting. I will indeed check it out.
> > >
> > > Cliff
> > >
> > >
> > > From: "Dmitri Trembovetski" <[EMAIL PROTECTED]>
> > > To: "Clifford Lyon" <[EMAIL PROTECTED]>
> > > Cc: <[EMAIL PROTECTED]>
> > > Sent: Friday, August 13, 2004 9:58 AM
> > > Subject: Re: [JAVA2D] Transparent internal frames
> > >
> > >
> > > >
> > > > Hello,
> > > >
> > > > could it be that some of your transparent components don't set
> > > > 'opaque' property to false and not filling the whole area they're
> > > > responsible for? This may cause the artifacts you're
> > > > seeing.
> > > >
> > > > Check out these articles, the may have some relevant info:
> > > > http://java.sun.com/products/jfc/tsc/articles/swing2d/index.html
> > > >
> http://java.sun.com/products/jfc/tsc/articles/fill-article1/index.html
> > > >
> > > > Thank you,
> > > > Dmitri
> > > >
> > > > On Thu, Aug 12, 2004 at 11:41:29PM -0400, Clifford Lyon wrote:
> > > > > Hello list, I have a Java 2D application where I show an image,
> and then display a transparent internal frame over the image that exposes
> controls to the user for adjusting parameters. Everything works fine,
> except when moving the knob on my JSlider, the internal frame background
> fills with random stuff. Any way around that? Custom painting?
> > > > >
> > > > > tia
> > > > >
> > > > >
> ===========================================================================
> > > > > To unsubscribe, send email to [EMAIL PROTECTED] and include in
> the body
> > > > > of the message "signoff JAVA2D-INTEREST". For general help, send
> email to
> > > > > [EMAIL PROTECTED] and include in the body of the message
> "help".
> >
> >
> ===========================================================================
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff JAVA2D-INTEREST". For general help, send email to
> > [EMAIL PROTECTED] and include in the body of the message "help".
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".