title: How to fit Image size to JFrame Size?
body: <p>I have a <code>JPanel</code> into a <code>JFrame</code>. I loaded a picture on the <code>JPanel</code> but its shown just a part of the picture: This is the part of the code where i did it:</p>
  
  <pre><code>JPanel panelImg = new JPanel()
  {
      public void paintComponent(Graphics g)
      {
          Image img = new ImageIcon("Welcome.png").getImage();
          Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
          setPreferredSize(size);
          setMinimumSize(size);
          setMaximumSize(size);
          setSize(size);
          setLayout(null);
          g.drawImage(img, 0, 0, null);
      }
  };
  mainFrame.add(panelImg);
  </code></pre>
  
  <p>So this is how it looks like:</p>
  
  <p><img src="https://i.stack.imgur.com/D60M6.png" alt="Picture 1"></p>
  
  <p>The complete picture looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/xLO5N.jpg" alt="enter image description here"></p>
  
  <p>Is there a way to scale the picture to the <code>JFrame</code>s size? Thanks in advance</p>