Hi, the problem with calculating the total amount, only the last amount is displayed from the list, it is necessary that everyone should be considered ... I will be grateful for the help
public void display() { defaultTableModel.getDataVector().removeAllElements(); //deleted defaultTableModel.fireTableDataChanged(); //deleted //создаем таблицу try { List<Record> records = RecordDao.getDao().queryForAll(); //запросить все данные из таблицы своей бд // перебираем все объекты и добавляем их втаблицу for (Record record : records) { if (employee.getId() == record.getEmployee_id()) { Object[] row = new Object[]{ record, // объект в целом employee.getName(), // из первой таблицы где только имена record.getMoney(), // выплаты DateUtils.convert(record.getDate()), // задали дату в приемлимый текст (07.02.12 15:34) }; defaultTableModel.addRow(row); jLabel.setText(String.valueOf("Общая сумма всех выплат: " + record.plusSum(record.getMoney()))); jLabel.setSize(150, 20); jLabel.setLocation(10, 220); jPanel.add(jLabel); } } } catch (SQLException e) { e.printStackTrace(); } } Method for adding in class Record
public int plusSum(int allMoney){ allMoney = allMoney + money; return allMoney; }