get cells odf a JTable
- by tuxou
hi
how to display a row of a jtable in a from of JTextField when click on the row,
( I need this to edit the data base from the JTable )
My table model
static class TableDataModel extends AbstractTableModel
{
private List nomColonnes;
private List tableau;
public TableDataModel(List nomColonnes, List tableau){
this.nomColonnes = nomColonnes;
majDonnees(tableau);
}
public void majDonnees(List nouvellesDonnees){
this.tableau = nouvellesDonnees;
fireTableDataChanged();
}
public int getRowCount(){
return tableau.size();
}
public int getColumnCount(){
return nomColonnes.size();
}
public Object getValueAt(int row, int col){
return ((ArrayList)( tableau.get(row))).get(col);
}
public String getColumnName(int col){
return nomColonnes.get(col).toString();
}
public Class getColumnClass(int c)
{
return getValueAt(0,c).getClass();
}
public boolean isCellEditable(int row, int col){
return true;
}
public void setValueAt(Object value, int row, int col)
{
((List)tableau.get(row)).set(col,value);
fireTableCellUpdated(row, col);
//i suppose i should update the database here
}
}