java - How to access columns by column index? -


    model = new defaulttablemodel(data, columnnames)      {                     @override         public string getcolumnname(int col) {             return (string) columnnames[col];         }     };     table = new jtable(model);      (int tc=0; tc<table.getcolumncount(); tc++)         table.getcolumn(tc).setcellrenderer(new textarearenderer()); 

i need access columns column index. following error occurs:

exception in thread "awt-eventqueue-0" java.lang.illegalargumentexception: identifier not found @ javax.swing.table.defaulttablecolumnmodel.getcolumnindex(unknown source)     @ javax.swing.jtable.getcolumn(unknown source) 

you need use column name column, following:

 (int tc=0; tc<table.getcolumncount(); tc++)         table.getcolumn(columnnames[tc]).setcellrenderer(new textarearenderer()); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -