How to set the background of a JPanel as an image
Hi everyone,
Could anyone help me on how to set up an image background in JPanel? For example, in a chess game, I want to have an image board instead of having cells with color. What I did was
First I overriddent the paint method in JPanel ie:
public void paint(Graphics g) {
super.paint(g);
g.drawImage(backgroundImage, 0, 0, sizeX, sizeY, this)
}
Then , I added pieces (also JPanels which images) on this panel...When I run it, the pieces were drawed first, then the backgoundImage appeared and overlapped it. All I could see on the Panel was just the backgoundImage....I must be doing something wrong here..
Any help would be appreciated.
Thank you,
Tam

