java - In JTable ,I create custom table model by extendind AbstractTableModel and use it , only the default column name(A,B,C,D,..) appear -


i using class , table heading appears b c d .

class customtablemodel extends abstracttablemodel
{

 string[] columnnames = {"firstname","lastname","contact","email"};<br/> //private vector<string> columnnames = new vector<string>();  private vector<string[]> data = new vector<string[]>();   customtablemodel()   {         string[] = {"a","s","d","f"};         this.data.addelement(a);   }  public int getcolumncount() {     int columncount = columnnames.length;     return columncount; } public int getrowcount() {     int rowcount = data.size();     return rowcount; } public object getvalueat(int rowindex, int columnindex) {     return data.get(rowindex)[columnindex]; } public class<?> getcolumnclass(int columnindex) {     return super.getcolumnclass(columnindex); } public string getcolumnname(int column) {<br/> return super.getcolumnname(column); } 

}
. . . how create object jtable

jtable table = new jtable(new customtablemodel());

please edit code

public string getcolumnname(int column) { return columnnames[column]; } 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -