title: Fit JTable to fill the JPanel
body: <p>Hi here are my codes for my table settings:</p>
  
  <pre><code>String [] column = {"MacAddress","PcName","OperatingSystem","IpAddress","Port","Status"};
      model = new DefaultTableModel(0,column.length);
      model.setColumnIdentifiers(column);
      mainTable = new JTable(model);
      mainTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
      for(int i=0;i&lt;=column.length-1;i++){
      mainTable.getColumnModel().getColumn(i).setPreferredWidth(300);
      }
      pane = new JScrollPane(mainTable);
      pnlTabel = new JPanel();
      pnlTabel.setBorder(BorderFactory.createTitledBorder(""));
      pnlTabel.setPreferredSize(new Dimension(dim.width*70/100, dim.height*60/100));
      pnlTabel.add(pane);
  addMainPanel(pnlTabel);
  </code></pre>
  
  <p>Here is my addMainPanel() function:</p>
  
  <pre><code>public void addMainPanel(Component pnl){
      mainPanel.add(pnl);
      mainPanel.revalidate();
  }
  </code></pre>
  
  <p>And here is my code for my mainPanel:</p>
  
  <pre><code>    mainPanel = new JPanel();
  mainPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
  add(mainPanel,"Center");
  </code></pre>
  
  <p>and I'm using border layout for my frame:</p>
  
  <pre><code>setLayout(new BorderLayout(0,0));
  </code></pre>
  
  <p>My problem is that, even i use this set of code to set my JTable to fit but it seems to fail all the this, this code:</p>
  
  <pre><code> mainTable.setAutoResizeMode(JTa![enter image description here][1]ble.AUTO_RESIZE_OFF);
  for(int i=0;i&lt;=column.length-1;i++){
  mainTable.getColumnModel().getColumn(i).setPreferredWidth(300);
  }
  </code></pre>
  
  <p>When is use that code, my jtable does not resize but only add on a horizontal scroll bar at the bottom.</p>