finalement j'ai réussi à faire ce que je voulais mais je trouve que c'est cradoc, si quelqu'un avait une suggestion voici le code
import javax.swing.*;
import java.awt.*;
import java.sql.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.table.*;
import javax.swing.event.TableModelEvent;
import javax.swing.event.*;
public class JIFScrollTable extends JScrollPane {
private
public JIFtable (Vector title) {
String[] h = {"Envoi O/N","Fichier","Descriptif","Date MAJ","Sensibilité"};
abstractModel am = new abstractModel(h);
//JIFTableModel TM = new JIFTableModel();
}
}
class JIFtableRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected, boolean hasFocus,int row, int column) {
if (value instanceof Boolean) {
JCheckBox checkBox = new JCheckBox();
checkBox.setSelected(((Boolean)value).booleanValue());
checkBox.setHorizontalAlignment(JLabel.CENTER);
checkBox.setBackground(Color.red);
return checkBox;
} else {
String str = (value == null) ? "" : value.toString();
setForeground((row%2 == 0)?Color.red:Color.green);
setBackground((row%2 == 0)?Color.green:Color.red);
return super.getTableCellRendererComponent(table,str,isSelected,hasFocus,row,column);
}
}
}
class abstractModel extends AbstractTableModel {
private String[] headers = null;
private Vector values;
public abstractModel(String[] headers)
{
this.headers = headers;
this.values = new Vector();
}
public abstractModel(String[] headers,Vector values)
{
this.headers = headers;
this.values = values;
}
public abstractModel()
{
this.values = new Vector();
}
public void addRow(Vector newRow)
{
values.add(newRow);
fireTableRowsInserted(values.size()-1, values.size()-1);
}
public void setValueAt (Object o,int r,int c) {
((Vector)values.elementAt(r)).setElementAt(o,c);
}
public void deleteRow(Vector row)
{
int index = values.indexOf(row);
values.remove(row);
fireTableRowsDeleted(index, index);
}
public boolean isCellEditable(int row, int col) {return col==0;}
public int getRowCount() { return values.size(); }
public int getColumnCount() { return headers.length; }
public String getColumnName(int c) { return headers[c]; }
public Object getValueAt(int row, int col) {
return ((Vector)values.elementAt(row)).elementAt(col);
}
/*public Class getColumnClass(int c) {
if (getValueAt(0, c) instanceof Boolean ) {
try {return Class.forName("java.lang.Boolean" );} catch (Exception e) {return null;}
} else {
return getValueAt(0, c).getClass();
}
}*/
}