title: Resize window calls paintComponent each time Window is resized?
body: <p>Why does the paintComponent update everytime I resize the Window?  </p>
  
  <p>This is the class that I'm adding to a JPanel that adds to a JFrame. Is the object being called each time the window is re-sized or what is exactly happening with the paint component?</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Font;
  import java.awt.Graphics;
  import java.awt.Graphics2D;
  import java.util.Random;
  
  import javax.swing.JComponent;
  import javax.swing.JPanel;
  
  class DrawString extends JPanel {
      public void paint(Graphics g) {
          Graphics2D g2 = (Graphics2D)g;
          Font font = new Font("Serif", Font.PLAIN, 10);
          g2.setFont(font);
          g2.drawString("Test string",randInt(1,1000), randInt(1, 1000)); 
  
          for(int i = 0; i &lt; 100; i++) {
              g.setColor(new Color(randInt(1,255), randInt(1,255),randInt(1,255)));
              g.drawLine(randInt(1,1000), randInt(1,1000), randInt(1,1000), randInt(1,1000));
          }
      }
      protected void paintComponent(Graphics g) {
          // TODO Auto-generated method stub
          super.paintComponent(g);
          super.setBackground(new Color(100,100,100));
          paint(g);
      }
      public static int randInt(int min, int max) {
  
          // Usually this can be a field rather than a method variable
          Random rand = new Random();
  
          // nextInt is normally exclusive of the top value,
          // so add 1 to make it inclusive
          int randomNum = rand.nextInt((max - min) + 1) + min;
  
          return randomNum;
      }
  }
  </code></pre>