title: How to set background logo in my JPanel or into JFrame?
body: <p>How can I set the <code>wall1.jpg</code> as background to my <code>JFrame</code> or <code>JPanel</code>?</p>
  
  <pre><code>public class JBackGroundImageClass extends JFrame
  {
    Image img;
    private final JPanel JPanel;
  
    public JBackGroundImageClass()
    {
      setLayout (new BorderLayout ());    
      setBounds(22,33,400, 400);
      setVisible(true);
  
      img = Toolkit.getDefaultToolkit().createImage("wall1.jpg");    
      JPanel = new JPanel()
      {
        public void paintComponent(Graphics g)
        {img = Toolkit.getDefaultToolkit().createImage("wall1.jpg");
          g.drawImage(img, 0, 0, null);
        }
      };
  
      this.add("North" , JPanel);
      JPanel.setSize(400, 400);
      JPanel.setBackground(Color.red);
      JPanel.setVisible(true);
  
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
  
  
    public static void main(String[] args) 
    {
      new JBackGroundImageClass().setVisible(true);
    }
  
  }
  </code></pre>