title: How do I add a background image to a JPanel?
body: <p>I have a JFrame and the JPanel is inside it. My game's background is completely black as the entities are on top of it. I would just like to change the background into an image from my computer the "simplest" way without having to change much.</p>
  
  <pre><code>public Game() {
      // Frame
      JFrame container = new JFrame("Space Invaders");
  
      // Resolution
      JPanel panel = (JPanel) container.getContentPane();
      panel.setPreferredSize(new Dimension(800,600));
      panel.setLayout(null);
  
      // Canvas Size
      panel.setBounds(0,0,800,600);
      panel.add(this);
  
      // Window Visible
      container.pack();
      container.setResizable(false);
      container.setVisible(true);
  
      container.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
              System.exit(0);
          }
      });
  }
  </code></pre>