Te pongo un ejemplo mas completo
   Código PHP:
    public class MainDesktopPane extends JPane{
 
    private Image image;
    
    public MainDesktopPane() {
        super();
        image = new ImageIcon(getClass().getResource("/images/fondo.jpg")).getImage();
    }
 
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        int h = (int)image.getHeight(null)/2;
        int w = (int)(image.getWidth(null)/2);
        int x = (int)getWidth()/2 - w;
        int y = (int)getHeight()/2 - h;
        g.drawImage(image, x, y, null);
    }
} 
    
  La clase lo que hace es colocar la imagen fondo.jpg  como fondo en el jpanel, lo coloca en el centro del jpanel 
espero que te ayude 
salu2