public void loadTableData() { while (tableModel1.getRowCount() > 0) { tableModel1.removeRow(0); } vatList = dbValue.getVatDetail(); yearList = dbValue.getFinancialYearDetail(); /* * Collections.sort(yearList, new Comparator<FinancialYearModal>() { * * @Override public int compare(FinancialYearModal year1, * FinancialYearModal year2) { * * if(year1.getStartYear()==year2.getStartYear()) return 0; else return * year1.getStartYear()-year2.getStartYear(); * * } }); */ for (int i = 0; i < vatList.size(); i++) { int startYear = 0, endYear = 0; vatModel = vatList.get(i); for (FinancialYearModal yearModel : yearList) { if (yearModel.getYearId() == vatModel.getYearId()) { startYear = yearModel.getStartYear(); endYear = yearModel.getEndYear(); } } tableModel1.addRow(new Object[] {i + 1, vatModel.getVatPercent(), startYear, endYear}); } }
// this method every time load the rackList from database and then display // it in table public void loadTableData() { int j = 0; while (j < tableModel.getRowCount()) { tableModel.removeRow(j); } rackList = dbValue.getRackDetail(tableid.getStoreId(comboBox1.getSelectedItem().toString())); for (int i = 0; i < rackList.size(); i++) { RackModel rack = rackList.get(i); tableModel.addRow(new Object[] {i + 1, rack.getRackName()}); } }