java - How to add a row to JTable after populating data using DbUtils.resultSetToTableModel? -
i have jtable defined in way:
public jtable table_1; model_3 = new defaulttablemodel(); table_1 = new jtable(model_3); scrollpane_5.setviewportview(table_1);
add row:
model_3.addrow(new object[]{table.getvalueat(row,0) , table.getvalueat(row,1) ,table.getvalueat(row,2) , commentfood });
remove row:
model_3.removerow(row); //row integer
until here, used work properly. can see table defined public because need fill jframe in way:
takeorder = new takeorder(); //get data db resultset to.table_1.setmodel(dbutils.resultsettotablemodel(resultset));
if fill table in way , try add or remove model_3
, not work! suggestion how can add or remove table after using dbutils.resultsettotablemodel(resultset)
appreciated.
as couldn't find information on internet , saw couple of people asked same question no answer. came solution:
if (formout) { (int = 0; < table_1.getrowcount(); i++) { model_3.addrow(new object[]{table_1.getvalueat(i,0), table_1.getvalueat(i, 1), table_1.getvalueat(i, 2)}); } } formout = false; table_1.setmodel(model_3);
fromout
boolean check if have used model table. if add data table previous model, , reference model table. can add model well.
Comments
Post a Comment