I've tried to set a background image to my JPanel, that holds some other components like Jlabel,JCheckBox,JTextField.I did add the background by creating another class and extending JPanel, and so overriding paintComponent().the image is been set perfectly but those labels and ... , won't get displayed.only buttons get displayed and that when I bring the mouse over them(checkboxes too, but, when they get displayed they contain their own background, which interferes with the image).
My code:
public class ImagePanel extends JPanel {
private Image image;
ImagePanel(String path){
this(new ImageIcon(path).getImage());
}
ImagePanel(Image image){
this.image=image;
Dimension size=new Dimension(796, 481);
setSize(size);
setLayout(null);
}
@Override
public void paintComponent(Graphics g) {
//numbers are the size of the main JPanel
g.drawImage(image,0,0,796,481, this);
}
}
and then added its object to my main JPanel, which holds components.for those components, i have only set the size and location nothing else. please help.
thanks in advance.
The answer is found thank you all for your participation.the answer is in the comments.