JTable duplicate values in row

前端 未结 3 1055
春和景丽
春和景丽 2020-11-21 13:43

I have a JTable populated with a custom DataModel (pasted below) and when I call the populate() method, it appears to populat

3条回答
  •  名媛妹妹
    2020-11-21 14:20

    You could try to make the changes of populate more atomic.

    public void populate(Collection c) {
        ArrayList> data2 = new  ArrayList>();
        for(Item i : c.getItems()) {
            ArrayList row = new ArrayList();
            for(Property p : i.getProperties().values()) {
                row.add(p.toString());
            }
            data2.add(row);
        }
        data = data2;
        fireTableDataChanged();
    }
    

    I am guessing that populate is called again before a prior populate call finished. And probably c is changed during its iteration.

提交回复
热议问题