Столбцы имен в JTable

Я работаю над программой для небольшого магазина. Когда я нажимаю кнопку «Отчет», должна отображаться таблица, подобная этой:

enter image description here

Имена столбцов «A», «B» ... «N» должны быть именами сотрудников. Но я не могу понять, как это сделать. Вот мой код:

public void Inform()
{
    String[] employee;
    String[] product[];
    this.setLayout(null);

    Inform=new JTable(nulo, employee.length);

     model = new DefaultTableModel() {

            private static final long serialVersionUID = 1L;

            @Override
            public int getColumnCount() {
                return 1;
            }

            @Override
            public boolean isCellEditable(int row, int col) {
                return false;
            }

            @Override
            public int getRowCount() {
                return Inform.getRowCount();
            }
        };

        headerTable = new JTable(model);

       for (int i = 0; i < Inform.getRowCount(); i++) 
            headerTable.setValueAt(product[i], i, 0);


        headerTable.setShowGrid(false);
        headerTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        headerTable.setPreferredScrollableViewportSize(new Dimension(50, 0));
        headerTable.getColumnModel().getColumn(0).setPreferredWidth(50);

        scrollPane = new JScrollPane(Inform);
        scrollPane.setRowHeaderView(headerTable);
        scrollPane.setBounds(5,5,500,500);
        scrollPane.setEnabled(false);
        this.add(scrollPane);


}

Сотрудник и продукт меняются в зависимости от того, сколько введено. nulo - сколько товаров готово к продаже.

5
задан Tom 12 December 2018 в 13:15
поделиться