Bonjour,
Je suis débutant en swing et je trouve un problème dans le JCombobox ds le rafraichissement ou l’ajout. J’explique mon problème
J’ai 3 classe :
1)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
classe Personne contient nom,prenom,age :
public class Personne {
private String nom;
private String prenom;
private String age;
public Personne(String nom,String prenom,String age)
{	
	this.nom=nom;
	this.prenom=prenom;
	this.age=age;
}
public String	GetNom(){return nom;}
}
2)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
classe liste personne qui contient un attribut :
import java.util.Vector;
public class Liste_Personne {
	Vector<Personne> L=new Vector();
	Liste_Personne()
	{
		 Personne P1= new Personne("Fabbien","Pierre","23");
		 L.add(P1);
		 Personne P2= new Personne("Fadoua","Micheal","30");
		 L.add(P2);	
	}
}
3) une interface GUI
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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import java.util.Vector;
import javax.swing.*;
import javax.swing.border.TitledBorder;
 
public class GUI implements ActionListener{
private	 JFrame cadre;
private	 JPanel pane,pane_per;
private	 JLabel label;
private	 JComboBox list;
private      JButton nouveau,Ajout;
//
private      JLabel N,Pr,A;
private      TextField T1,T2,T3;
//
 
Vector <String>  v = new Vector<String>();
Liste_Personne Lis =new Liste_Personne();
Iterator it;
 
public GUI()
{
		cadre=new JFrame("Personne");
		cadre.setSize(380,400);
 
		pane=new JPanel();
		pane.setSize(380,400);
	      label=new JLabel("Les noms des Personnes sont :");
 
 
	    it = Lis.L.iterator();
		while (it.hasNext()) 
		{
			   Personne P= (Personne) it.next();
			   v.add(P.GetNom());
		}
 
	    list = new JComboBox(v);
	    pane.add(label);  
	    pane.add(list);
	    nouveau  =new JButton("Nouveau Personne");
	    nouveau.addActionListener(this);
 
	    pane_per=new JPanel();
		pane_per.setBorder(new TitledBorder(" Nouvelle Personne"));
 
 
	    N=new JLabel(" Nom  ");
	    Pr=new JLabel(" Prenom ");
		A=new JLabel(" Age ");
		T1=new JTextField (8);
		T2=new JTextField (8);
		T3=new JTextField (3);
		Ajout=new JButton(" Ajouter ");
		Ajout.addActionListener(this);
		pane_per.add(N);   pane_per.add(T1);
		pane_per.add(Pr);  pane_per.add(T2);
		pane_per.add(A);   pane_per.add(T3);
		pane_per.add(Ajout);
		pane_per.setVisible(false);	    
 
	    pane.add(nouveau);
	    pane.add(pane_per);
	    cadre.getContentPane().add(pane);
		cadre.setVisible(true);	
}
 
	/**
         * @param args
         */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
          GUI inst=new GUI();
	}
 
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		if(arg0.getSource()==nouveau)
		{
			pane_per.setVisible(true);
		}
		if(arg0.getSource()==Ajout)
		{
			Personne NOUV=new Personne(T1.getText(),T2.getText(),T3.getText());
			Lis.L.addElement(NOUV);
			list.updateUI();		    
		}
	}	
}
Le probleme reside lorsque j’ajoute une personne elle n’a pas ete ajoute dans le JCombobox malgre j’ai fait list.updateUI

Merci pour vos aides