Hi all,
I have just created a JFrame with a JPanel. i have welcome class which extends JPanel, in its paintcomponent(Grapics g),method i have painted a Picture as a background to the JPanel. My problem is that when i start the JFrame it doesnt have that pic painted there.. when ever i resize it.. then that picture will appear .. Please if anybody know the soln for this problem..Pls let me know..The codes is as follows..
Code
---------------------------------------------------------------------------
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.ImageObserver;
import java.net.URL;
import javax.swing.JPanel;
public class RemoteMainPanel extends JPanel implements ImageObserver {
private Image bgImage;
RemoteMainPanel()
{
URL ImgUrl = getClass().getResource("bg.jpg");
bgImage =Toolkit.getDefaultToolkit().getImage(ImgUrl);
}
public void paint(Graphics g) {
g.drawImage(bgImage, 0, 0, this);
}
}
Thank you
Regards