I am trying to add a jTable in my class MyPage which has a tabbedPane in it. I am able to call my jTable in it and the table is perfectly visible but the column headers are not. I have even tried to add my table in a scrollPane but that also doesn't help me. Also, I am using Eclipse , I don't think that it is necessary to tell this but just to let y'all know. Here is my class MyPage and the table's code in it
Public MyPage(){
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setBorder(new LineBorder(new Color(0, 0, 0), 2));
tabbedPane.setBounds(10, 122, 744, 386);
contentPane.add(tabbedPane);
JPanel panel_4 = new JPanel();
tabbedPane.addTab("Customers list", null, panel_4, null);
panel_4.setLayout(null);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(0, 0, 735, 354);
scrollPane.setLayout(null);
table = new JTable();
table.setGridColor(new Color(0, 0, 0));
table.setBounds(10, 10, 715, 332);
panel_4.add(scrollPane.add(table));
conn = javaconnect.ConncrDB();
Table();
}
And here is the function through which I am calling the table entries of my database.
public void Table() {
try {
String sql = "select * From Balances";
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JDialog dialog = new JDialog();
dialog.setAlwaysOnTop(true);
JOptionPane.showMessageDialog(dialog, e );
}finally {
try {
rs.close();
pst.close();
} catch (Exception e2) {
JDialog dialog = new JDialog();
dialog.setAlwaysOnTop(true);
JOptionPane.showMessageDialog(dialog, e2 );
}
}
}
I have tried every possible method I could find on Internet to resolve it but the table is not showing any column headers but when I open the model window in the properties of my jTable in windows builder design window the colomn headers are shown.