title: How to make JTable headers visible in JFrame?
body: <p>I wanted to display table records with their respective columns from a MySQL database.</p>
  <p>This is what I tried to do:</p>
  <pre><code>(e.getSource().equals(btnClick)) {
  
   //Table
   JTable table = new JTable();
   JScrollPane scroll = new JScrollPane(table);
                                              
  String[] columnNames = new String[] {&quot;Staff ID&quot;, &quot;Name&quot;, &quot;Email&quot;, &quot;Address&quot;, &quot;Phone&quot;,&quot;Gender&quot;};
                                              
  table.setBounds(500,50, 550,300); 
  
  try {
                                                          
    String sql = &quot;SELECT * FROM staffs&quot;;
  
    PreparedStatement pstmt = ConnectDb.getConnection().prepareStatement(sql);
    ResultSet rslt = pstmt.executeQuery();
                                                                                                                    
                                                          
    table.setModel(net.proteanit.sql.DbUtils.resultSetToTableModel(rslt));  
                                                          
  } catch (Exception ex) {
                                                               
   JOptionPane.showMessageDialog(null,ex,&quot;Error&quot;,JOptionPane.ERROR_MESSAGE);                                                             
   frm.setVisible(true);
  
  }
  
  }
  
    frm.add(btnClick);
    frm.add(table); 
  </code></pre>
  <p>As a result, its only the rows data which are shown while the table headers remain hidden.</p>
  <p>Does anyone has a solution for this?</p>