There are two tables with DefaultTableModel and collections to store all added rows and columns for both tables. Delete a row in the model is obtained through getDataVector, and to remove the method columns in the model did not find the code snippet (for investigation by psychics):

JButton butOne = new JButton("Уменьшить"); butOne.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Number--; DefaultTableModel tableModel = (DefaultTableModel)table.getModel(); DefaultTableModel tableModel2 = (DefaultTableModel)table2.getModel(); tableModel.getDataVector().remove(Vectors1.get(Vectors1.size() - 1)); tableModel.getDataVector().remove(Columns.get(Columns.size()-1)); <- //вот эта строка и должна по идее удалять столбец, но она работает только для строк tableModel2.getDataVector().remove(Vectors2.get(Vectors2.size()-1)); Vectors1.remove(Vectors1.get(Vectors1.size()-1)); Vectors2.remove(Vectors2.get(Vectors2.size()-1)); Columns.remove(Columns.get(Columns.size()-1)); tableModel.fireTableDataChanged(); tableModel2.fireTableDataChanged(); } }); 

    1 answer 1

    If anyone is interested, I did this: clicking on the reduce button creates a new table model that is less by one column and puts this model in the table