title: How do I change between two JTables?
body: <p>So I have a JTable inside a JScrollPane inside a frame that works. What I want to do is to change the table that is being showed to another table that displays some other information and has more/less columns/rows. How do I do this?</p>
  
  <p>I have tried stuff like putting another table in the ScrollPane but that doesn't work and if I re-put the ScrollPane in the frame it disappears.</p>
  
  <p>EDIT:</p>
  
  <p>I think this is all the code that has to do with this problem. I simply call the funktions to change the view.</p>
  
  <pre><code>    Object[][] userData = new Object[50][6];
      userTable = new JTable(userData, new String[] { "Namn", "Adress", 
              "Telefon", "Personnummer", "PIN", "Antal cyklar" }) {
          public boolean isCellEditable(int rowIndex, int colIndex) {
              return false;
          }
      };
      userTable.setSelectionMode(0);
      userTable.getTableHeader().setReorderingAllowed(false);
      Object[][] bikeData = new Object[50][7];
      bikeTable = new JTable(bikeData, new String[] { "Ägare", "Streckkod", 
              "Färg", "Märke", "Ram-nummer", "Senast hämtad", "Senast lämnad" }) {
          public boolean isCellEditable(int rowIndex, int colIndex) {
              return false;
          }
      };
      bikeTable.setSelectionMode(0);
      bikeTable.getTableHeader().setReorderingAllowed(false);
      JScrollPane tablePane = new JScrollPane(bikeTable);
      frame.add(tablePane);
  
      frame.setVisible(true);
  }
  
  public void displayUsers(){
      tablePane.setViewportView(userTable);
  }
  
  public void displayBikes(){
      tablePane.setViewportView(bikeTable);
  }
  </code></pre>