package ru.egspt; import javax.swing.table.AbstractTableModel; public class ReportTableModel extends AbstractTableModel{ private String[] header = {"id", "login", "mail"}; private Object[][] data; public ReportTableModel(Data data){ //заполняем модель данными int i = 0; while (i < data.getUsers().size()){ this.data[0][i] = data.getUsers().get(i).getId(); this.data[1][i] = data.getUsers().get(i).getLogin(); this.data[2][i] = data.getUsers().get(i).getMail(); i++; } } @Override public int getRowCount() { return getData().length; } @Override public int getColumnCount() { return getHeader().length; } @Override public Object getValueAt(int rowIndex, int columnIndex) { return getData()[rowIndex][columnIndex]; } /** * @return the data */ public Object[][] getData() { return data; } /** * @param data the data to set */ public void setData(Object[][] data) { this.data = data; } /** * @return the header */ public String[] getHeader() { return header; } /** * @param header the header to set */ public void setHeader(String[] header) { this.header = header; } }