title: Drawing simple rectangles in my JPanel doesn't work
body: <p>The end goal for this code so far is to draw a bunch of rectangles that slowly increase in height (from left to right across the window), so that it forms sort of a right triangle of rectangles, that takes up the bottom right half of the window. Code compiles fine, but when when run, all the window displays is a JFrame named "Selection Sort" with a dark gray background (all fine, that's what it's supposed to do), and no rectangles (not fine). Code for the 2 classes:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.util.*;
  
  public class SelectionSort extends JPanel {
  
      private Bar arr[];
      private JFrame frame; 
      private int amountBars;
  
      public SelectionSort(int amountBars) {
          frame = new JFrame("Selection Sort");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setVisible(true);
          frame.setSize(700, 500);
          setBackground(Color.darkGray);
          frame.setContentPane(this);
          this.amountBars = amountBars;
          arr = new Bar[amountBars];
          for(int i = 0; i &lt; arr.length; i++) {
              arr[i] = new Bar(new Color(i, i, i), i);
          }
          paintComponent(frame, getGraphics());
          }
  
      public void paintComponent(JFrame frame, Graphics g) {
          for(int i = 0; i &lt; arr.length; i++) {
              g.setColor(arr[i].getColor());
              g.fillRect(i * ((int) getSize().getWidth() / arr.length), (int) getSize().getHeight(), (int) (getSize().getWidth() / arr.length), i * ((int) getSize().getHeight() / arr.length));
          }
      }
  
      private void delay(int ms) {
          try {
              Thread.sleep(ms);
          } catch (Exception ex) {
              ex.printStackTrace();
          }
      }
  
      public static void main(String[] args) {
          SelectionSort sort = new SelectionSort(100);
          sort.repaint();
      }
  
  }
  
  
  public class Bar {
  
      private int size;
      private Color color;
      private int listNum;
  
      public Bar(Color color, int listNum) {
          this.color = color;
          this.listNum = listNum;
      }
  
      public Color getColor() {
          return color;
      }
  
      public int getListNum() {
          return listNum;
      }
  
      public void setColor(Color color) {
          this.color = color;
      }
  
      public void setListNum(int listNum) {
          this.listNum = listNum;
      }
  }
  </code></pre>
  
  <p>I have some thoughts on how to do this differently, but I thought I'd just ask at this point to see. If this isn't solved, then would putting a drawRect method IN my Bar class, and then saying <code>arr[i].draw(getGraphics)</code>  in the paintComponent method, or something like that work better?
  Note, the color of the bar is not important rn, but also how would I make it a rainbow gradient across the window? I don't think <code>new Color(i, i, i)</code> will work. Thanks!</p>