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
Post a Comment