Forse sbaglio nell'uso degli indici delle righe della tabella ma ho qualche problema con i due metodi sopra citati:
e l'inserimento pare che funge anche se quel system out stampa valori assurdi, cioè in pratica:codice:public void appendRow(String a, String b, String c, String d, String e, String f) { Vector<Object> row = new Vector<Object>(); JButton cancel = new JButton(); cancel.setIcon(cancicon); cancel.setContentAreaFilled(false); // no riempimento cancel.setBorder(null); // no bordo cancel.setFocusPainted(false); // no focus cancel.setFocusable(false); cancel.addActionListener(this); cancel.repaint(); row.add(cancel); row.add(a); row.add(b); row.add(c); row.add(d); row.add(e); row.add(f); data.add(row); System.out.println("RIGA AGGIUNTA: "+getRowCount()); fireTableRowsInserted(getRowCount()-1,getRowCount()-1); }
AGGIUNGO PRIMA RIGA ----->RIGA AGGIUNTA: 1
AGGIUNGO SECONDA RIGA ----->RIGA AGGIUNTA: 2
AGGIUNGO TERZA RIGA ----->RIGA AGGIUNTA: 3
CANCELLO TUTTE LE RIGHE TRANNE UNA (che non mi è consentita cancellare, ci sarà qualche errore negli indici passati all'algoritmo)
provo ad AGGIUNGERE NUOVA RIGA e magia ----->RIGA AGGIUNTA: 2
RIGA AGGIUNTA: 1
Anche se in realtà li me ne inserisce correttamente una.
PERCHE'!?!?
Per quanto riguarda la cancellazione delle righe, devo aver toppato anche li, come ti dicevo posso cancellarle tutte, in ordine sparso, e tutto fila liscio fino a che non mi ritrovo solo una riga in tabella, a quel punto nada...ed esce il messaggio: "DataModel, no row for button!!!???"
Il codice è questo:
codice:public void actionPerformed(ActionEvent e) { int row = getRowForButton(e.getSource()); if (row == -1) { throw new RuntimeException("DataModel, no row for button!!!???"); } System.out.println("RIGA CANCELLATA: "+row); data.remove(row); fireTableRowsDeleted(row,row+1); }

Rispondi quotando