I think this code will help u...
You have to override the paint method. The image should have the
same size of the panel.
public class urPanel extends JPanel {
Image imBase; /*bacdkground image for the frame*/
/**
Constructor to this class, image is loaded and painted here
*/
public urPanel() {
this.setLayout(null);
MediaTracker media = new MediaTracker(this);
imBase = Toolkit.getDefaultToolkit().getImage(this.getClass().
getResource("urbgimage.gif"));
media.addImage(imBase,0);
try{
media.waitForAll();
}catch(Exception e){
e.printStackTrace();
}
this.setSize(780,580);
this.setVisible(true);
}
/**
Function to paint the panel with the image
*/
public void paintComponent(Graphics g){
g.drawImage(imBase,0,0,this);
}
}
Best Regards -- Reji.
www.atinav.com
>
> Today's Topics:
>
> 1. Re: Set JPanel backgound to gif/jgp image (Ruel Elvambuena)
>
> --__--__--
>
> Message: 1
> From: "Ruel Elvambuena" <[EMAIL PROTECTED]>
> To: "Gakkan Krishnarao" <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
> Subject: Re: Set JPanel backgound to gif/jgp image
> Date: Tue, 23 Apr 2002 08:43:51 -0700
>
> override the public void paintComponent(Graphics g) method.
> ----- Original Message -----
> From: "Gakkan Krishnarao" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, April 21, 2002 10:53 PM
> Subject: Set JPanel backgound to gif/jgp image
> >
> >
> > Could any body throw light on how to set a JPanel's backgound to any
> gif/jpg
> > image. So that the objects like JButtons/JTextAreas always are above
this
> > image.
> >
> > Thanx....
>
>
>
> --__--__--
>
> _______________________________________________
> Advanced-swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/advanced-swing
>
>
> End of Advanced-swing Digest
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing