title: How can I pass values to paintComponent
body: <p>I have an array of 100 random ints. I want to create a bar graphic from them. I know how to create a single rectangle in a frame but without passing values.</p>
  
  <p>This is the draw class:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  
  public class draw extends JPanel
  {
      public void drawing() {
  
          repaint();
      }
  
  public void paintComponent(Graphics g) {
  
          super.paintComponent(g);
          g.setColor(Color.BLUE);
          g.fillRect(100, 150, 12, 3);
      }
  }
  </code></pre>
  
  <p>I want to replace the values in g.fillRect(100,150,12,3) with my random int values. But since i call repaint() from main to call paintComponent, i cant pass values to paintComponent. How do i do it? if its impossible, what alternatives do i have?</p>