Auf Thema antworten

Guten Tag,


ich versuche aus meiner ArrayList ein Wert löschen leider klappt dies nicht wie ich will:(


Probiere das grade so:


[code=Java]

public class test TableModel extends AbstractTableModel {

    Object[][] objects = new Object[1][3];

    private StammdatenDelegate delegate = StammdatenDelegate.getInstance();

    ArrayList<test > list = new ArrayList<test>();

   

    int COL_POS_NAME=0;

    int COL_POS_AKTIV=1;

    int COL_POS_SORT=2;

   

    int row=0;

   

    public void holeDaten(){

         list = (ArrayList<test >) delegate.suchenallertests();

         for(test entity:list){

             addRow(entity, row);

             row++;

         }     

    }

    private Object[][] data = new Object[][]{};

 

    public String getColumnName(int pos) {

        String[] cols = new String[]{

            "Name", "Aktiv", "Sotierung"

        };

        return cols[pos];

    }

    public int getRowCount() {

        return data.length;

    }

    public int getColumnCount() {

        return 3;

    }

    public boolean isCellEditable(int row, int column) {

        return true ;

    }

    public void addRow(int position) {

        position = Math.max(0, Math.min(data.length, position));

            Object[][] newObjects = new Object[data.length + 1][];

   

           

            System.arraycopy(data, 0, newObjects, 0, position);

            System.arraycopy(data, position, newObjects, position + 1,

                data.length - position);


            newObjects[position] = new Object[getColumnCount()];

            data = newObjects;


            fireTableRowsInserted(position, position);

        }

    public void addRow(test entity, int positionRow){

         addRow(positionRow);

         data[positionRow][COL_POS_NAME] = entity.getName();

         data[positionRow][COL_POS_AKTIV]= entity.getAkiv();

         data[positionRow][COL_POS_SORT] = entity.getSortierung();


     }

    public void setValueAt(Object value, int row, int col) {

            data[row][col] = value;

            fireTableCellUpdated(row, col);

        }

    public void deleteRow(int positionRow) {

               list.remove(positionRow);

               holeDaten();

               

    }

        @Override

    public Object getValueAt(int rowIndex, int columnIndex)

        {

            return data[rowIndex][columnIndex];

        }

}



[/code]



Oben