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
|
class ClientsModel extends AbstractTableModel
{
private ResultSetMetaData rsmd;
private ResultSet Table;
ClientsModel()
{
String Requete ="SELECT * FROM CLIENT ";
try
{
Table = Variables.stat.executeQuery(Requete);
rsmd = Table.getMetaData();
}
}
catch (SQLException e) { }
}
public int getColumnCount()
{
try
{
return rsmd.getColumnCount();
}
catch (SQLException e) { return 0 ;}
}
public int getRowCount() {
try
{
Table.last();
return Table.getRow();
}
catch (SQLException e) { return 0 ;}
}
public String getColumnName(int col)
{
try
{
return rsmd.getColumnName(col +1);
}
catch (SQLException e)
{return "";}
}
public Object getValueAt(int ligne, int col)
{
try
{
Table.absolute(ligne + 1);
return Table.getObject(col +1);
}
catch (SQLException e) { return null; }
}
}
public class MonAfficheurCellule implements TableCellRenderer
{
JCheckBox Chek = new JCheckBox("",true );
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected,boolean hasFocus, int row, int col)
{
if(col==4)if ( (Integer)value == 0 ) Chek.setSelected(true);
else Chek.setSelected(false);
return Chek;
}
} |
Partager