title: how to resize image while resize frame using drawImage
body: <p>I have a little problem. I'm learning about Java forms and I want to resize my Image while I resize my form. But unfortunately I only resize form. Image have still these same dimensions. How can i rescale image?  What should i change? What i do wrong?
  I enclose the code:</p>
  
  <pre><code>    package przegladarka;
  import java.io.*;
  import java.util.ArrayList;
  import java.awt.*;
  
  import javax.swing.*;
  public class view extends JPanel {
      Image imag; 
      Dimension size;
      public static int framew=300;
      public static int frameh=300;
      static String[] children;
      static ArrayList&lt;String&gt; sciezki = new ArrayList&lt;String&gt;(); 
  
      public static void main(String[] args) {
          File folder = new File("./zdjecia/");
          visitAllFiles(folder);
  
          JFrame frame = new JFrame("Przegladarka");
          frame.setSize(300, 300);
  
          frame.setVisible(true);
          frame.getContentPane().add(new MyCanvas());
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   
      }
  
  
  
      public static void visitAllFiles(File dir) {
          if (dir.isDirectory()) {
              children = dir.list();
              for (int i = 0; i &lt; children.length; i++) {
                  visitAllFiles(new File(dir, children[i]));
                  System.out.println(""+children[i]);
                  Image imag = Toolkit.getDefaultToolkit().getImage(children[i]); 
              }
  
          } else {
              System.out.println(dir.getAbsolutePath() + " is being processed.");
              sciezki.add(dir.getAbsolutePath());
          }
      }
  }
  class MyCanvas extends JComponent{
      public void paint(Graphics g){
          Graphics2D g2d = (Graphics2D) g;
  
          for(int i=0; i&lt;view.sciezki.size();i++){
  
              Image imag = Toolkit.getDefaultToolkit().getImage(view.sciezki.get(i));
  
  
          g2d.drawImage(imag, 0, 0, this);
  
          g2d.finalize();
          }
      }
  }
  </code></pre>