title: Drawing an Image to a JPanel within a JFrame
body: <p>I am designing a program that contains two JPanels within a JFrame, one is for holding an image, the other for holding GUI components(Searchfields etc). I am wondering how do I draw the Image to the first JPanel within the JFrame?</p>
  
  <p>Here is a sample code from my constructor : </p>
  
  <pre><code>public UITester() {
      this.setTitle("Airplane");
      Container container = getContentPane();
      container.setLayout(new FlowLayout());
      searchText = new JLabel("Enter Search Text Here");
      container.add(searchText);
      imagepanel = new JPanel(new FlowLayout());
      imagepanel.paintComponents(null);
     //other constructor code
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public void paintComponent(Graphics g){
      super.paintComponents(g);
      g.drawImage(img[0], -50, 100, null);
  }
  </code></pre>
  
  <p>I was trying to override the paintComponent method of JPanel to paint the image, but this causes a problem in my constructor when I try to write : </p>
  
  <pre><code>imagepanel.paintComponents(null);
  </code></pre>
  
  <p>As it will only allow me to pass the method null, and not Graphics g, anybody know of a fix to this method or another method i can use to draw the image in the JPanel? Help is appreciated! :) </p>
  
  <p>All the best and thanks in advance!
  Matt</p>