File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes why there's no header in my JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "why there Watch "why there New topic

why there's no header in my JTable

david hu
Ranch Hand

Joined: Jul 20, 2001
Posts: 143
I use these following code to initialize the JTable(of course, there are some other codes to setup the TableColumn objects). My problem is that the header of the table is not shown up? Can anyone give me some direction?

I know that in the constractor of JTable, I can provide a parameter corresponding to the columns headers. But since I use default construct, if there any way to setup the header later?

JTable contractorTable = new JTable();
ContractorTableData data = new ContractorTableData();//extends abstractTableModel
S Perreault
Ranch Hand

Joined: Oct 29, 2003
Posts: 37
Did you add this method to your implementation of AbstractTableModel?

/** Returns the column name for a particular column. */
public String getColumnName(int col)

I agree. Here's the link:
subject: why there's no header in my JTable
It's not a secret anymore!