Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JTable column headers not showing up

843804Dec 21 2004 — edited Dec 21 2004
I have a JTable inside a JScrollPane which, in turn, is inside a JTabbedPane.
I created a TableModel which extends AbstractTableModel as per the java Swing Tutorial examples.
In that model is an Object[][] object for the data called rowData, and all the data displays in the table perfectly.
I also have a String[] object called columnNames to define the column headers. ..the column names are coded directly into the object.
i.e.:
String[] columnNames = {"John", "Janet", "Jamie", "Jennifer"};
But the column names don't display at all.....all I get in the column headers is 'A', 'B', 'C', etc.
I need to know either
1)how to set this up correctly in the first place or
2)how I can reset the columns manually.

I have tried adding the table 2 ways..as follows...but neither one gets the headers right:
JScrollPane jScrollPane = new javax.swing.JScrollPane(getTable());
or
JScrollPane jScrollPane.setViewportView(getTable());
Note: getTable()..is where the
new javax.swing.JTabel(new TableModel())
stuff is done.
thx, ESW
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 18 2005
Added on Dec 21 2004
6 comments
1,018 views