Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

JTable Eintrag löschen

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

mein kleines Problem ist das ich ein Eintrag löschen will, leider klappt dies nicht wie ich will:(

Die Methode deleteRow macht einfach nothing :(

Bitte um hilfe


public class STableModel extends AbstractTableModel {

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

    private StammdatenDelegate delegate = StammdatenDelegate.getInstance();

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

    private final static Logger log = Logger.getLogger( STableModel.class );

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


    int COL_POS_NAME=0;

    int COL_POS_AKTIV=1;

    int COL_POS_SORT=2;


    int row=0;


    public void holeDaten(){

    	list = (ArrayList<SEntity>) delegate.suchenallerVerantwortlicher();

    	for(S entity:list){

     		addRow(entity, row);

     		row++;

     	}  	

    }  

    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(VerantwortlicherEntity 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);

        }  

		@Override

	    public Object getValueAt(int rowIndex, int columnIndex)

	    {

	        return data[rowIndex][columnIndex];

	    }




	public void speicherDaten(){

		delegate.speichernS(list);	

	}


	public void deleteRow(int position) {

		//delegate.loeschenDatensatz(S, user);

		list.remove(position);

        fireTableRowsDeleted(position, position);	 	

    }







Was heißt "macht einfach nothing"? Die Methode wird nicht aufgerufen? Ein Methodenaufruf innerhalb der Methode tut etwas, das Du nicht erwartest / anders erwartest?

Während Du weitere Informationen gibst, solltest Du vielleicht die Formatierung Deiner Quellcodes kritisch betrachten.

Peter

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.