1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
this.model=new MonModel (this.data,this.columnNames);
this.table = new JTable (model);
protected class MonModel extends DefaultTableModel
{
public MonModel (Object[][] data, String[] columnNames)
{
super(data,columnNames);
}
public int getColumnCount ()
{
return super.getColumnCount();
}
public int getRowCount ()
{
return super.getRowCount();
}
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
{
super.setValueAt(aValue, rowIndex, columnIndex);
fireTableCellUpdated(rowIndex,columnIndex);
}
public String getColumnName (int col)
{
return super.getColumnName(col);
}
public void setColumnName(Object newName,int col)
{
super.columnIdentifiers.setElementAt(newName,col);
}
public Object getValueAt (int row, int col)
{
return super.getValueAt(row,col);
}
public void addColumn(Object newName, Object[] column)
{
super.addColumn(newName, column);
}
public void addRow(Object[] ligne)
{
super.addRow(ligne);
}
public void removeRow(int ligne)
{
//System.out.println("ligne dans le data = "+ligne);
super.removeRow(ligne);
//fireTableRowsDeleted(ligne,ligne);
}
public boolean isCellEditable (int row, int column)
{
if(isEditableCase(row,column))
{
return true;
}
else
return false;
}
public void fireTableStructureChanged()
{
fireTableChanged(new TableModelEvent(this,TableModelEvent.HEADER_ROW));
}
} |
Partager