title: JTable Missing Column Headers
body: <p>Really simple question. Don't bash me please. :)</p>
  
  <p>I created a table model by extending <code>AbstractTableModel</code> as follows:</p>
  
  <pre><code>public class InventoryTableModel extends AbstractTableModel {
      private static final String[] COLUMN_NAMES = { "On Sale", "Name", "Selling Price", "Description" };
  
      @Override
      public int getColumnCount() {
          return COLUMN_NAMES.length;
      }
  
      @Override
      public int getRowCount() {
          return 0;
      }
  
      @Override
      public String getColumnName(int columnIndex) {
          return COLUMN_NAMES[columnIndex];
        }    
  
      @Override
      public Object getValueAt(int rowIndex, int columnIndex) {
          return null;
      }    
  }
  </code></pre>
  
  <p>Next, I create a <code>JTable</code> using this table model and show it in a panel with layout <code>BorderLayout</code>:</p>
  
  <pre><code>JTable inventoryTable = new JTable(new InventoryTableModel());        
  mainPanel.add(inventoryTable, BorderLayout.CENTER);
  </code></pre>
  
  <p>Note that <code>mainPanel</code> eventually ends up inside a scroll pane:</p>
  
  <pre><code>scrollPane.setViewportView(mainPanel);
  </code></pre>
  
  <p>For some reason I am not seeing the table headers. Here is all my program shows:</p>
  
  <p><img src="https://i.stack.imgur.com/bw42k.png" alt="Missing Column Headers"></p>
  
  <p>(Note, the white space is where the table is.)</p>
  
  <p>To make sure the table is being placed properly I modified the <code>getRowCount</code> method to return 1:</p>
  
  <pre><code>@Override
  public int getRowCount() {
      return 1;
  }
  </code></pre>
  
  <p>And now this is what I see:</p>
  
  <p><img src="https://i.stack.imgur.com/BpPY2.png" alt="Missing Column Headers - 1 Row"></p>
  
  <p>Can anyone tell me why my column headers are missing? I know it's something simple but my brain is fried and I just can't seem to figure it out.</p>
  
  <p>Thank you.</p>
  
  <p>Update, based on <a href="https://stackoverflow.com/a/22734780/2587435">Josh M's answer</a> I placed the table inside a scroll pane. That worked but this is how my application looks now:</p>
  
  <p><img src="https://i.stack.imgur.com/jT8OD.png" alt="Table Inside Scroll Pane"></p>
  
  <p>Note the vertical scroll bar.</p>