Bonjour
j'ai parcouru le forum, mais je n'arrive toujours pas a identifier mon problème
je n'ai pas pu afficher les éléments de ma table dans mon combobox.
dans le 1er code, il m'affiche que la dernière ligne de ma table:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
final ResultSet produits;
int nbp = 0;			
JComboBox comboBoxPro = new JComboBox();
 
produits = state.executeQuery("SELECT NomProduit FROM Produit");
while(produits.next()){
   comboBoxPro.setModel(new DefaultComboBoxModel(new String[] {produits.getString("NomProduit")}));
   nbp++;
}
 
comboBoxPro.setBounds(123, 192, 115, 22);
getContentPane().add(comboBoxPro);
mais le second ne m'affiche rien, meme pas la cmbobox vide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
final ResultSet produits;
int nbp = 0;
 
JComboBox comboBoxPro = new JComboBox();
 
produits = state.executeQuery("SELECT NomProduit FROM Produit");
 
while(produits.next()){
	comboBoxPro.addItem(produits.getString(nbp));
	nbp++;
}
 
comboBoxPro.setBounds(123, 192, 115, 22);
getContentPane().add(comboBoxPro);
quelqu un peut m aider??
il me manque surement un petit truc bete ^^"