• Post Reply Bookmark Topic Watch Topic
  • New Topic

table column names not showing up

 
Ashish Sarin
author
Ranch Hand
Posts: 444
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I am creating a JTable using AbstractTableModel. When the JTable shows up it does give all the column values correctly but the column names are not being displayed.
Can anyone tell me how to fix this problem ?
regards
ashish sarin
 
Wael Atef
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
try to override the method getColumnName in AbstractTableModel and return your column names. For Example
public String getColumnName(int col)
{
String[] colNames = {"A","B","C"};
return colNames[i];
}
and override the the method getColumnCount to return your column number
public int getColumnCount()
{
return 3;
}
i hope that works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!