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
| try {
cn = new Connexion();
///////***//////////////
// String[] tableColumnsName = {"Référence", "Nom", "Type", "Quantité", "Prix unitaire", "Seuil minimal"};
// DefaultTableModel aModel = new DefaultTableModel();
// aModel.setColumnIdentifiers(tableColumnsName);
jTable1.setModel(
new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null}
},
new String [] {
"Numéro produit", "Nom Produit", "Prix unitaire", "Quantité", "Somme"
}
) {
Class[] types = new Class [] {
java.lang.Integer.class, java.lang.String.class, java.lang.Float.class, java.lang.Integer.class, java.lang.Float.class
};
boolean[] canEdit = new boolean [] {
false, false, false, true, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
//////*********///////////////////
ResultSet rss = cn.getResultat("Select ref,nom,pu from produit");
// stmt1 = cn.getConnection().createStatement();
// ResultSet rss = stmt1.executeQuery(requ);
java.sql.ResultSetMetaData rsmd = rss.getMetaData();
int colNo = rsmd.getColumnCount();
while (rss.next()) {
Object[] objects = new Object[colNo];
for (int i = 0; i < colNo; i++) {
objects[i] = rss.getObject(i + 1);
}
aModel.addRow(objects);
}
jTable1.repaint();
} catch (Exception ex) {
Logger.getLogger(CommandeAjouterProduit.class.getName()).log(Level.SEVERE, null, ex);
}
} |
Partager