title: Dynamically adding JTable to JScrollPane
body: <p>I have a table that I want to populate when the user prompts me to do so.  Problem is, I can't anticipate how many rows the table will end up having.  In the constructor for my panel where the table will be displayed I have</p>
  
  <pre><code>    // add empty scrollPane to JPanel which will later hold table
                scrollPane = new JScrollPane(); 
      add(scrollPane);
  </code></pre>
  
  <p>This class contains a method that will be called when I want to finally display the table</p>
  
  <pre><code>    public void displayTable(String[] columnNames, String[][] dataValues)
  {
      table = new JTable(dataValues, columnNames);
      table.setPreferredScrollableViewportSize(new Dimension(300, 80)); 
      table.setFillsViewportHeight(true); 
      scrollPane.add(table);
  
      this.setVisible(true);
      scrollPane.repaint();
  
  }
  </code></pre>
  
  <p>Problem is, the table never displays.  I just see an outline of where the ScrollPane is with no table inside.  Why isn't the table displaying and how can I fix it?</p>