Bonjour ,

Problématique basique que je viens de me heurter , voila :
J'ai une JFrame ou j'ai mis tous mes composants
J'ai une class qui me permet de récupérer le (getSource() ) de ma JFrame principale .
Sur une des action , j'ouvre une autre petite JFrame mais lorsque je veux créer un evemenent lié a cet JFrame ==> ça plante .

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
public class ActionFrame extends AbstractAction implements ActionListener  {
 
	FramePr a;
         FramePanel b; 
 
 
	public ActionFenetre(FramePr aa) {
		// TODO Auto-generated constructor stub
		this.a=aa; 
	}
 
 
 
	public ActionFenetre(FramePanel cc) {
		// TODO Auto-generated constructor stub
		this.c=cc;
	}
public void actionPerformed(ActionEvent ev) {
 
	Object sourceEv = ev.getSource() ; 
	int index = a.ComboBox.getSelectedIndex();
 
// quand je fait mon choix ==> j'ai une frame qui s'ouvre 
 
if (sourceEv == a.ComboBox && index==2)
	{
			String[] champs = {"a","b","c" } ;
			String[] btnSM ={"Ajouter","Valider","Annuler"};
			c = new FrameFenetre(0,champs.length,"TOTO" ,champs , btnSM,index);
 
	}
if(sourceEv ==c.jpfSM.btnFrame[0] && index ==1 ) 
   {
 // ça ne marche pas ! 
       Objet o = new Objet("aaa");
      a.panel.add(o) ;
 
  }
Lorsque je rempli les données nécessaire sur ma nouvelle Frame ==> ça plante !

Voila la class FramePanel qui fait appel a une autre class

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
public class FramePanel extends JFrame {
 
 
 
	FramePr main = new FramePr(); 
 
	private int IndexChoice = 0; 
 
	public FramePanel (int posChamps , int posBtn, String nameDialog , String[] Champs ,String[] btnSM ,int index)
	{
 
		jpfSM = new JPanelFrame(nameDialog);
		JLabel lbl = new JLabel(String.valueOf(index));
		tk = this.getToolkit(); 
		dim = tk.getScreenSize(); 
		int width = dim.width; 
		int height = dim.height; 
		jpfSM.addTxt(1,posChamps,Champs);
		jpfSM.addButton(0, posBtn, btnSM); 
		p = new JPanel();
		p.setLayout(new BorderLayout());
		p.add("North",jpfSM);
		p.add("South",lbl);
		add(p);
		setIndexChoice(Integer.valueOf(lbl.getText()));
 
		setSize(width/3,height/3);
		setLocation(width/3, height/3);
		//setModal(true);
		for(int i = 0 ; i<3 ; i++)
		{
		jpfSM.btnFrame[i].addActionListener(this);
		}
		setVisible(true);
 
	}
En gros , lorsque je clique sur le Bouton de la nouvelle fenetre , j'ajoute un objet sur la fenetre principale ! .