title: Adding JScrollPane to JTable
body: <p>I've been working on this for awhile but can't seem to get the scroll pane added. I'm creating a JFrame, adding a JTable to that frame and then updating cells in a for loop. But I can't get the JScrollPane to add without it crashing. I also couldn't declare the column headers without it crashing. Any ideas would really be appreciated.</p>
  
  <pre><code> frame6.setIconImage(Toolkit.getDefaultToolkit().getImage("images\\iconimage.jpg"));
   frame6.pack();
   frame6.setResizable(false);
   frame6.setVisible(true);
   frame6.setSize(400,200);
   frame6.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
   Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
   int w = frame6.getSize().width;
   int h =  frame6.getSize().height;
   int x = (dim.width-w)/2;
   int y = (dim.height-h)/2;
   frame6.setLocation(x, y);
  
   JPanel btnPnl = new JPanel(new BorderLayout());
   JPanel topBtnPnl = new JPanel(new FlowLayout(FlowLayout.TRAILING));
   JPanel bottombtnPnl = new JPanel(new FlowLayout(FlowLayout.CENTER));
  
   JButton close = new JButton("Close");
   bottombtnPnl.add(close);
  
   btnPnl.add(topBtnPnl, BorderLayout.NORTH);
   btnPnl.add(bottombtnPnl, BorderLayout.CENTER);
  
  
  defaultTableModel model = new DefaultTableModel(list.size(), 6);
  JTable table = new JTable(model);
  frame6.add(table, BorderLayout.NORTH);
  
  
  
  JScrollPane jps = new JScrollPane();
  table.add(jps);
  
  
  table.setValueAt("FIRST NAME", 0,0);
  table.setValueAt("LAST NAME", 0, 1);
  table.setValueAt("CLUB", 0, 2);
  table.setValueAt("POSITION", 0, 3);
  table.setValueAt("AGE", 0, 4);
  table.setValueAt("COUNTRY", 0, 5);
  
  int j = 0;
  
  for(i = 0; i &lt; PlayerManager.list.size(); i++){
  
       if(list.get(i).getPosition().toUpperCase().equals(pPosition.toUpperCase()))
      {
      table.setValueAt(PlayerManager.list.get(i).getfName(), j+1, 0);
          table.setValueAt(PlayerManager.list.get(i).getlName(), j+1, 1);
      table.setValueAt(PlayerManager.list.get(i).getClub(), j+1, 2);
      table.setValueAt(PlayerManager.list.get(i).getPosition(), j+1, 3);
      table.setValueAt(PlayerManager.list.get(i).getAge(), j+1, 4);
      table.setValueAt(PlayerManager.list.get(i).getNationality(), j+1, 5);
      j++;
          }
      }
  
  frame6.add(table, BorderLayout.CENTER);
  frame6.add(btnPnl, BorderLayout.SOUTH);
  
  frame6.setTitle("Player Table");
  
  
  close.addActionListener(new ActionListener(){
  
      public void actionPerformed(ActionEvent e){
      frame6.setVisible(false);
      frame6.dispose();
  }
   });
  </code></pre>