I am filling a JTable with data from a database. I am have subclassed AbstractTableModel and passed the reference to the JTable. However, how do I manage to extract the column names in the database and set them as "headers" in the JTable?
Thanks in advance.
I already have this, in the console the header names display but I do not have a column in the GUI. I have attached the JTable to a tab in a tabbed pane.
@Override
public String getColumnName(int column) {
try {
System.out.println(dbhandler.getMetaData().getColumnName(column + 1));
return dbhandler.getMetaData().getColumnName(column + 1);
} catch (SQLException e) {
e.printStackTrace();
return "";
}
}