----- Original Message -----
Sent: Saturday, August 14, 2004 3:46
PM
Subject: Re: [JAVA2D] Transparent
internal frames
Here is a short piece of code that demonstrates
the effect. First, if I click on the slider, the Internal Frame
gets repainted on its own content frame. Then, if I move the
slider, I see knob artifacts. The latter is easy to fix by
repainting in the actionListener; the former I have not figured out, but
I'm probably doing something wrong with the layered pane.
Thanks - also feel free to steer me to another
interest group.
Cliff
/*****************************/
import java.awt.*;
import
java.awt.image.BufferedImage;
import java.io.File;
import
javax.imageio.ImageIO;
import javax.swing.*;
public class TestJFrame
{
public static void main (String args[])
{
try
{ JFrame frame
= new
JFrame();
BufferedImage image = ImageIO.read(new
File(args[0]));
ImageScreen imageScreen = new
ImageScreen(image);
SliderFrame sliderFrame = new
SliderFrame();
sliderFrame.setBounds(0,0,image.getWidth()/2,image.getHeight()/2);
sliderFrame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(imageScreen);
frame.getLayeredPane().add(sliderFrame,JLayeredPane.DEFAULT_LAYER);
frame.pack();
frame.setSize(image.getWidth(),image.getHeight());
frame.show();
} catch (
Exception e )
{
e.printStackTrace();
}
}
}
class ImageScreen extends
JComponent
{ BufferedImage image;
public
ImageScreen(BufferedImage bi){
super();
image =
bi;
}
public void
paintComponent(Graphics g){
Rectangle r = this.getBounds();
if (image != null
)
g.drawImage(image,0,0,r.width,r.height,this);
}
}
class SliderFrame extends JInternalFrame
{ JSlider
slider = new JSlider();
public
SliderFrame()
{
super();
slider.setOpaque(false);
this.setOpaque(false);
slider.setBackground(new
Color(0,0,0,0));
this.setBackground(new
Color(0,0,0,0));
this.getContentPane().add(slider);
}
}
----- Original Message -----
Sent: Friday, August 13, 2004 9:56
AM
Subject: Re: [JAVA2D] Transparent internal
frames
> Hi,
>
> It's pretty difficult to know
from your quick description where the
> problem would lie.
> There
is no inherent problem with using transparent internal frames in
>
Swing, but
> you need to make sure to set and use the opacity property
of the
> component(s)
> appropriately and to do the right thing
during paintComponent(). Other than
> that very high-level
suggestion, it's hard to know what else to say.
> There could
> be
a bug lurking here in how we implement scrolling (devCopyArea) on
>
translucent
> components, but a test case would sure help...
>
> Chet.
>
>
> 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".
===========================================================================
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".