Code

ZLATANBEN Messages postés 22 Date d'inscription jeudi 29 avril 2010 Statut Membre Dernière intervention 18 mai 2010 - 13 mai 2010 à 14:20
ZLATANBEN Messages postés 22 Date d'inscription jeudi 29 avril 2010 Statut Membre Dernière intervention 18 mai 2010 - 13 mai 2010 à 16:17
salut;
je veut savoir la methode qui me permet de d ajouter un elemet dans une liste de jcombobox mais au debut de liste n'est pas au dernier

8 réponses

cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
13 mai 2010 à 14:26
Salut,

Un petit tour dans la javadoc et tu as ta réponse : la méthode int) insertItemAt.
______________________________________

AVANT de poster votre message, veuillez lire, comprendre, et appliquer notre réglement
0
ZLATANBEN Messages postés 22 Date d'inscription jeudi 29 avril 2010 Statut Membre Dernière intervention 18 mai 2010
13 mai 2010 à 14:44
merci;
mais autre probleme je veut que l element reste dans la zone de texte c à d areste afficher
0
cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
13 mai 2010 à 14:51
Salut,

Je vois pas trop où est le problème... montre nous ton code.
______________________________________

AVANT de poster votre message, veuillez lire, comprendre, et appliquer notre réglement
0
ZLATANBEN Messages postés 22 Date d'inscription jeudi 29 avril 2010 Statut Membre Dernière intervention 18 mai 2010
13 mai 2010 à 14:56
je veut afficher les variables apr,cati,siti dans les jcombobox qui convient et voila le code;


try {
Statement res = con.createStatement();


ResultSet rep = res.executeQuery(reqq );


try{
while (rep.next()) {
String nui = rep.getString(1);

String idi = rep.getString(2);
String agi = rep.getString(3);
String profi = rep.getString(4);
String rei = rep.getString(5);
String siti = rep.getString(6);
String adi = rep.getString(7);
String vii = rep.getString(8);
String cod=rep.getString(9);
String cati=rep.getString(10);
String apr=rep.getString(11);

this.jTextField1.setText(nui);
this.jTextField2.setText(idi);
this.jTextField3.setText(agi);
this.jTextField4.setText(profi);
this.jComboBox1.insertItemAt(siti,0);
this.jTextField6.setText(adi);
this.jTextField7.setText(cod);
this.jTextField8.setText(vii);
this.jComboBox2.insertItemAt(cati,0);
this.jTextField9.setText(rei);

this.jComboBox3.insertItemAt(apr,0);



}



}catch ( SQLException ex ) {
System.err.println( );}



res.close();
}
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
13 mai 2010 à 15:33
Salut,

Pourquoi faire le setText à l'intérieur de ta boucle ? Fait les à la fin de ta boucle :
try{ 
while (rep.next()) { 
String nui = rep.getString(1); 

String idi = rep.getString(2); 
String agi = rep.getString(3); 
String profi = rep.getString(4); 
String rei = rep.getString(5); 
String siti = rep.getString(6); 
String adi = rep.getString(7); 
String vii = rep.getString(8); 
String cod=rep.getString(9); 
String cati=rep.getString(10); 
String apr=rep.getString(11); 

this.jComboBox3.insertItemAt(apr,0); 

} 
this.jTextField1.setText(nui); 
this.jTextField2.setText(idi); 
this.jTextField3.setText(agi); 
this.jTextField4.setText(profi); 
this.jComboBox1.insertItemAt(siti,0); 
this.jTextField6.setText(adi); 
this.jTextField7.setText(cod); 
this.jTextField8.setText(vii); 
this.jComboBox2.insertItemAt(cati,0); 
this.jTextField9.setText(rei); 


______________________________________

AVANT de poster votre message, veuillez lire, comprendre, et appliquer notre réglement
0
ZLATANBEN Messages postés 22 Date d'inscription jeudi 29 avril 2010 Statut Membre Dernière intervention 18 mai 2010
13 mai 2010 à 15:59
mon probleme que l element s ajoute dans la liste et ne s affiche pas dans la zone de texte
0
cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
13 mai 2010 à 16:04
Salut,

Et en rajoutant : this.jComboBox3.setText(apr);
______________________________________

AVANT de poster votre message, veuillez lire, comprendre, et appliquer notre réglement
0
ZLATANBEN Messages postés 22 Date d'inscription jeudi 29 avril 2010 Statut Membre Dernière intervention 18 mai 2010
13 mai 2010 à 16:17
j ai fais this.jComboBox3.setText(apr); mais elle marche pas et il met errur sous settext
0
Rejoignez-nous