title: I can't set an image background into a JPanel that was already created into a Frame
body: <p>So here's my code.. I can't make it work
  I have a created Panel made with palette in netbeans, it also has a couple of Labels and Buttons. I need to set a background to the panel and everything over it. What's wrong?</p>
  
  <pre><code>import java.awt.Dimension;
  import java.awt.Graphics;
  import java.awt.Image;
  import javax.swing.ImageIcon;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  
  
  public class PanelPrincipal extends javax.swing.JPanel {
  
  class ImagePanel extends JPanel {
  
      private Image img;
      public ImagePanel(String img) {
          this(new ImageIcon(img).getImage());
      }
  
      public ImagePanel(Image img) {
          this.img = img;
          Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
          setPreferredSize(size);
          setMinimumSize(size);
          setMaximumSize(size);
          setSize(size);
          setLayout(null);
      } 
  public void paintComponent(Graphics g){
      g.drawImage(img,0,0, null); 
  }
  }
          /**
           * Creates new form PanelPrincipal
           */
      public PanelPrincipal(VentanaPrincipal ventanaPrincipal) {
          initComponents();
  </code></pre>