Précédent   Forum du club des développeurs et IT Pro > Java > Interfaces Graphiques en Java
Interfaces Graphiques en Java Forum d'entraide pour les interfaces graphiques en Java (Swing, AWT, JFace, SWT, Graphisme 2D et 3D, clients riches, ...). Avant de poster -> Les cours sur les Interfaces Graphiques - FAQ GUI Java
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 26/12/2012, 11h56   #1
ghoriu
Invité de passage
 
Homme
Toulouse
Inscription : décembre 2012
Messages : 8
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Toulouse
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : décembre 2012
Messages : 8
Points : 0
Points : 0
Par défaut Problème enregistrement question

Bonjour, je sollicite votre aide pour m'aider dans mon problème.
En ce moment pour le cours de JAVA on nous demande de faire une application qui gère des sondages. Mon problème est le suivant :
Quand je teste une question (Je clique sur Oui et/ou Non pour ajouter des réponses) je n'arrive pas à enregistrer mes réponses pour les mettre dans une JComboBox. EN fait j'ai un menu principal où se trouve la Combo Box pour mettre toutes mes question ainsi que les réponses sous la forme : Question (RepOui/RepNon)-(NbOui/NbNon).
Donc quand je teste ma question j'aimerai qu'il se fasse une mise à jour de la combo box.
J'espère avoir étais assez clair dans mes explications.
ghoriu est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/12/2012, 12h10   #2
tchize_
Expert Confirmé Sénior
 
Avatar de tchize_
 
Homme
Responsable de service informatique
Inscription : avril 2007
Messages : 18 280
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : Belgique

Informations professionnelles :
Activité : Responsable de service informatique
Secteur : Service public

Informations forums :
Inscription : avril 2007
Messages : 18 280
Points : 32 756
Points : 32 756
Envoyer un message via MSN à tchize_ Envoyer un message via Skype™ à tchize_
Je ne sais pas si la JCombobox est le composant le plus approprié pour afficher une liste de résultas. JList serait peut-être plus approprié.

Cela dit, pour ajouter des éléments à un composant de ce type, il faut passer par le Model.

Code :
1
2
3
4
5
6
7
DefaultComboBoxModel model = new DefaultComboBoxModel();
JComboBox taBox = new JComboBox(model);
//.....
 
model.addElement("nouvel élément");
model.addElement("nouvel élément 2");
//etc.
__________________
⥀⥁ Чиз faq java, cours java, javadoc. Pensez à et
Laisse entrer le jour après une nuit sombre. Si tu es toujours là, tu n'es pas faite pour mourir.
tchize_ est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/12/2012, 12h34   #3
ghoriu
Invité de passage
 
Homme
Toulouse
Inscription : décembre 2012
Messages : 8
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Toulouse
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : décembre 2012
Messages : 8
Points : 0
Points : 0
Pour la comboBox j'ai tout ce qu'il faut.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public void majVueEditionSondage ()
	{
		QuestionBinaire q;
 
		this.libelle.setText ("Titre"+this.ces.getLibelleSondage());
		this.nbQ.setText("Nombre de questions : "+"("+this.ces.getNbQuestionsSondage()+")");
		this.jcb.removeAllItems();
 
		for (int i = 0; i < this.ces.getNbQuestionsSondage(); i++)
		{
			q = this.ces.getQuestionSondage(i);
 
			this.jcb.addItem(q.getQuestion() + " ("+q.getLibOui()+"/"+q.getLibNon()
					+ ")-("+q.getNbOui()+"/"+q.getNbNon()+")");		
		}
 
		this.jcb.setSelectedIndex(-1);
 
	}
Juste ce que je n'arrive pas à faire c'est d'actualiser cette combobox.
EN fait j'ai une fenetre pour "tester" une question et quand je clique sur "quitter" j'aimerai que la combobox se mettent à jour.
ghoriu est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/12/2012, 19h33   #4
tchize_
Expert Confirmé Sénior
 
Avatar de tchize_
 
Homme
Responsable de service informatique
Inscription : avril 2007
Messages : 18 280
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : Belgique

Informations professionnelles :
Activité : Responsable de service informatique
Secteur : Service public

Informations forums :
Inscription : avril 2007
Messages : 18 280
Points : 32 756
Points : 32 756
Envoyer un message via MSN à tchize_ Envoyer un message via Skype™ à tchize_
Tu ajoute un listener sur ta fenêtre pour être notifié quand on la ferme et tu met à jour, via le modèle, la combobox à ce moment là.
__________________
⥀⥁ Чиз faq java, cours java, javadoc. Pensez à et
Laisse entrer le jour après une nuit sombre. Si tu es toujours là, tu n'es pas faite pour mourir.
tchize_ est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 10h25   #5
ghoriu
Invité de passage
 
Homme
Toulouse
Inscription : décembre 2012
Messages : 8
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Toulouse
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : décembre 2012
Messages : 8
Points : 0
Points : 0
Sa je l'ai fait, j'ai ma fenetre pour tester et quand je quitte, via un bouton, je lui demande de faire la mise à jour comme précédemment sauf que sa me met des erreurs de partout
Exception occurred during event dispatching:
java.lang.NullPointerException
genre celle la d'erreur, et je pense que c'est à cause de la jcombobox.
ghoriu est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 10h57   #6
tchize_
Expert Confirmé Sénior
 
Avatar de tchize_
 
Homme
Responsable de service informatique
Inscription : avril 2007
Messages : 18 280
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : Belgique

Informations professionnelles :
Activité : Responsable de service informatique
Secteur : Service public

Informations forums :
Inscription : avril 2007
Messages : 18 280
Points : 32 756
Points : 32 756
Envoyer un message via MSN à tchize_ Envoyer un message via Skype™ à tchize_
Citation:
Envoyé par ghoriu Voir le message
Sa je l'ai fait, j'ai ma fenetre pour tester et quand je quitte, via un bouton, je lui demande de faire la mise à jour comme précédemment sauf que sa me met des erreurs de partout
Exception occurred during event dispatching:
java.lang.NullPointerException
genre celle la d'erreur, et je pense que c'est à cause de la jcombobox.
Ben déjà donne nous tes erreurs complète et ton code si tu veux qu'on t'aide. Le NullPointerException n'est pas du à ta combobox mais à de bourdes dans ton code (tu essaie de manipuler des objets qui n'existent pas)
__________________
⥀⥁ Чиз faq java, cours java, javadoc. Pensez à et
Laisse entrer le jour après une nuit sombre. Si tu es toujours là, tu n'es pas faite pour mourir.
tchize_ est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 15h02   #7
ghoriu
Invité de passage
 
Homme
Toulouse
Inscription : décembre 2012
Messages : 8
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Toulouse
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : décembre 2012
Messages : 8
Points : 0
Points : 0
La classe qui teste les questions
Code :
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
93
94
95
96
97
98
public class VueQuestionBinaire extends JDialog implements WindowListener
{
	private static final long serialVersionUID = -6635034758748579961L;
	private QuestionBinaire laQb;
	private JButton oui, non, enregistrer;
	private JLabel question, resultat;
	private JPanel bas;
	private VueEditionSondage ves;
 
	public VueQuestionBinaire  (Frame _f, String _t, QuestionBinaire _qb)
	{
		super(_f, _t, true);
		this.laQb = _qb;
		this.setSize(350, 200);
 
		// Boutons
		oui = new JButton (this.laQb.getLibOui());
		non = new JButton (this.laQb.getLibNon());
		enregistrer = new JButton ("Enregistrer");
 
		// Label
		question = new JLabel (this.laQb.getQuestion());
		resultat = new JLabel (this.laQb.resultatQuestionBinaire());
 
		// Container bas
		bas = new JPanel();
		bas.setLayout(new BorderLayout());
		bas.add(this.resultat, BorderLayout.NORTH);
		bas.add(this.enregistrer, BorderLayout.SOUTH);
 
		// Positionnement des boutons, label et container
		this.add(oui, BorderLayout.WEST);
		this.add(non, BorderLayout.EAST);
		this.add(question, BorderLayout.NORTH);
		this.add(bas, BorderLayout.SOUTH);
 
		// Listeners
		oui.addActionListener(new ValiderOui(this));
		non.addActionListener(new ValiderNon(this));
		enregistrer.addActionListener(new Enregistrer(this));
	}
	public VueEditionSondage getVes()
	{
		return this.ves;
	}
	public QuestionBinaire getQuestion()
	{
		return this.laQb;
	}
	public JLabel getResultat()
	{
		return this.resultat;
	}
	public void rafraichirVue()
	{
		this.resultat.setText(this.laQb.resultatQuestionBinaire());
	}
	public void windowClosing(WindowEvent we)
	{
		this.setVisible(false);
	}
	public void windowActivated(WindowEvent arg0) {}
	public void windowClosed(WindowEvent arg0) {}
	public void windowDeactivated(WindowEvent arg0) {}
	public void windowDeiconified(WindowEvent arg0) {}
	public void windowIconified(WindowEvent arg0) {}
	public void windowOpened(WindowEvent arg0) {}
}
class ValiderOui implements ActionListener
{
	private VueQuestionBinaire vqb;
	ValiderOui (VueQuestionBinaire v){this.vqb = v;}
	public void actionPerformed (ActionEvent ea)
	{
		this.vqb.getQuestion().enregOui();	
		this.vqb.rafraichirVue();
	}
}
class ValiderNon implements ActionListener
{
	private VueQuestionBinaire vqb;
	ValiderNon (VueQuestionBinaire v){this.vqb = v;}
	public void actionPerformed (ActionEvent ea)
	{
		this.vqb.getQuestion().enregNon();
		this.vqb.rafraichirVue();
	}
}
class Enregistrer implements ActionListener
{
	private VueQuestionBinaire vqb;
	Enregistrer (VueQuestionBinaire v){this.vqb = v;}
	public void actionPerformed (ActionEvent ea)
	{
		this.vqb.getVes().majReponse(this.vqb.getQuestion());
		this.vqb.setVisible(false);
	}
}
La vue principale
Code :
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
public class VueEditionSondage extends JFrame
{
	private static final long serialVersionUID = 7331007452704800860L;
	private ControleurEditeurSondage ces;
	private JLabel libelle, nbQ;
	private JTextField texte;
	private JComboBox jcb;
	private JButton supprimer, ajouter, tester, enreg, charger, nouveau, quitter;
	private JPanel grille, haut, milieu;
	private VueEditionQuestion veq;
 
	public VueEditionSondage (String _t, ControleurEditeurSondage _ces)
	{
		super (_t);
		this.ces = _ces;
 
		this.setBounds (20, 20, 600, 300);
		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE );
		// Composants
		// Label
		this.libelle = new JLabel ();
		this.nbQ = new JLabel("Nombre de questions : ", JLabel.CENTER);
		// Combo Box
		this.jcb = new JComboBox ();
		// Text
		this.texte = new JTextField(20);
		// Boutons
		this.supprimer = new JButton ("Supprimer Qu.");
		this.ajouter = new JButton ("Ajouter Qu.");
		this.tester = new JButton ("Tester Qu.");
		this.enreg = new JButton ("Enregister S.");
		this.charger = new JButton ("Charger S.");
		this.nouveau = new JButton ("Nouveau S.");
		this.quitter = new JButton ("Quitter");
 
		// Abonner un ecouteur aux boutons
		this.supprimer.addActionListener(new EcouteurSupp (this));
		this.quitter.addActionListener(new EcouteurQuit(this));
		this.tester.addActionListener(new EcouteurTest(this));
		this.ajouter.addActionListener(new EcouteurAjout(this));
		this.enreg.addActionListener(new EcouteurEnreg(this));
		this.charger.addActionListener(new EcouteurChrg(this));
		this.nouveau.addActionListener(new EcouteurNew(this));
 
		// Panel
		grille = new JPanel();
		grille.setLayout(new GridLayout(3, 3));
		grille.add(this.ajouter);
		grille.add(this.supprimer);
		grille.add(this.tester);
		grille.add(this.enreg);
		grille.add(this.charger);
		grille.add(this.nouveau);
		grille.add(this.quitter);
		haut = new JPanel();
		haut.setLayout(new FlowLayout());
		haut.add(this.libelle);
		haut.add(this.texte);
		milieu = new JPanel();
		milieu.setLayout(new BorderLayout());
		milieu.add(this.nbQ, BorderLayout.NORTH);
		milieu.add(this.jcb, BorderLayout.CENTER);
 
		// Positionnement des Panel
		this.add(grille, BorderLayout.SOUTH);
		this.add(haut, BorderLayout.NORTH);
		this.add(milieu, BorderLayout.CENTER);
 
		this.majVueEditionSondage ();
	}
 
	public void majReponse (QuestionBinaire q)
	{
		int index = this.jcb.getSelectedIndex();
		this.jcb.remove(index);
		this.jcb.addItem(new QuestionBinaire(q.getQuestion(), q.getNbOui(), q.getNbNon(), q.getLibOui(), q.getLibNon()));
	}
	public void majVueEditionSondage ()
	{
		QuestionBinaire q;
 
		this.libelle.setText ("Titre"+this.ces.getLibelleSondage());
		this.nbQ.setText("Nombre de questions : "+"("+this.ces.getNbQuestionsSondage()+")");
		this.jcb.removeAllItems();
 
		for (int i = 0; i < this.ces.getNbQuestionsSondage(); i++)
		{
			q = this.ces.getQuestionSondage(i);
 
			this.jcb.addItem(q.getQuestion() + " ("+q.getLibOui()+"/"+q.getLibNon()
					+ ")-("+q.getNbOui()+"/"+q.getNbNon()+")");		
		}
 
		this.jcb.setSelectedIndex(-1);
 
	}
	public JComboBox getCombo()
	{
		return this.jcb;
	}
	public ControleurEditeurSondage getControleur ()
	{
		return this.ces;
	}
	public VueEditionQuestion getEditionQuestion()
	{
		return this.veq;
	}
	public String getTitreSondage()
	{
		return this.texte.getText();
	}
}
class EcouteurSupp implements ActionListener
{
	private VueEditionSondage ves;
	public EcouteurSupp (VueEditionSondage v)
	{
		this.ves = v;
	}
	public void actionPerformed (ActionEvent ea)
	{
		int index;
		index = this.ves.getCombo().getSelectedIndex(); // on récupère l'index dans la JComboBox
		if (index == -1) // si -1 alors erreur
		{
			JOptionPane.showMessageDialog(this.ves, "Aucune question sélectionnée","Erreur",  JOptionPane.ERROR_MESSAGE);
		}
		else // sinon on appelle la méthode du controleur
		{
			this.ves.getControleur().controleurSupprimerQuestion(index);
		}
	}
}
class EcouteurAjout implements ActionListener
{
	private VueEditionSondage ves;
	public EcouteurAjout (VueEditionSondage v)
	{
		this.ves = v;
	}
	public void actionPerformed (ActionEvent ea)
	{
		VueEditionQuestion veq;
		veq = this.ves.getEditionQuestion();
		veq = new VueEditionQuestion(this.ves,"Saisie d'une question",  this.ves.getControleur());
		veq.setVisible(true);
	}
}
class EcouteurQuit implements ActionListener
{
	private VueEditionSondage ves;
	public EcouteurQuit(VueEditionSondage v)
	{
		this.ves = v;
	}
	public void actionPerformed (ActionEvent ea)
	{
		int option = 0;
		option = JOptionPane.showConfirmDialog(this.ves, "Confirmer la fermeture");
		if (option == 0)
		{
			System.exit(0);
		}
	}
}
class EcouteurTest implements ActionListener
{
	private VueEditionSondage ves;
	public EcouteurTest(VueEditionSondage v)
	{
		this.ves = v;
	}
	public void actionPerformed (ActionEvent ea)
	{
		int index = this.ves.getCombo().getSelectedIndex(); // On récupère l'index de la question sélectionnée dans le JComboBox
		QuestionBinaire qb;
		if (index == -1) // Si index = -1 donc si aucune question sélectionnée => message d'erreur
		{
			JOptionPane.showMessageDialog(this.ves, "Aucune question sélectionnée","Erreur",  JOptionPane.ERROR_MESSAGE);
		}
		else // Sinon on "envoie" au controleur la question que l'on veut tester en appelant la méthode controleurTesterQBDepuisEditeurSondage
		{
			qb = this.ves.getControleur().getQuestionSondage(index);
			this.ves.getControleur().controleurTesterQBDepuisEditeurSondage(qb);
		}
	}
}
class EcouteurEnreg implements ActionListener
{
	private VueEditionSondage ves;
	public EcouteurEnreg (VueEditionSondage v)
	{
		this.ves = v;
	}
	public void actionPerformed(ActionEvent ea)
	{
		this.ves.getControleur().controleurSauvegarderSondage();
	}
}
class EcouteurChrg implements ActionListener
{
	private VueEditionSondage ves;
	public EcouteurChrg (VueEditionSondage v)
	{
		this.ves = v;
	}
	public void actionPerformed(ActionEvent ea)
	{
		this.ves.getControleur().controleurChargerUnSondage();
	}
}
class EcouteurNew implements ActionListener
{
	private VueEditionSondage ves;
	public EcouteurNew (VueEditionSondage v)
	{
		this.ves = v;
	}
	public void actionPerformed(ActionEvent ea)
	{
		this.ves.getControleur().controleurNouveauSondage();
	}
Le controleur
Code :
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
public class ControleurEditeurSondage
{
	private Sondage sondageEdite;
	private VueEditionSondage ves;
	private VueQuestionBinaire vqb;
	private VueEditionQuestion veq;
 
	public ControleurEditeurSondage ()
	{
		this.sondageEdite = new Sondage ("");
		this.ves = null;
 
		// Titre et quelques questions pour tester ...
		// A enlever avant livraison
			this.sondageEdite.setLibSondage  (" de Sondage : ");
			this.sondageEdite.addQuestion (new QuestionBinaire ("Question 1"));
			this.sondageEdite.addQuestion (new QuestionBinaire ("Question 2", 5, 4, "Peut etre", "Sans doute pas"));
			this.sondageEdite.addQuestion (new QuestionBinaire ("Question 3"));
		// Fin initialisation pour tests
	}
 
	public void demarrerControleurEditeurSondage ()
	{
		if (this.ves == null)
		{
			this.ves = new VueEditionSondage ("Editeur de Sondage", this);
			this.ves.majVueEditionSondage();
			this.ves.setVisible (true);	
		}
	}
 
	// Accès aux données métier
 
	public String getLibelleSondage () { 
		return this.sondageEdite.getLibSondage();
	}
 
	public int getNbQuestionsSondage () { 
		return this.sondageEdite.getNbQuestions(); 
	}
 
	public QuestionBinaire getQuestionSondage (int index) {
		return new QuestionBinaire (
				this.sondageEdite.getQuestion(index).getQuestion(),
				this.sondageEdite.getQuestion(index).getNbOui(),
				this.sondageEdite.getQuestion(index).getNbNon(),
				this.sondageEdite.getQuestion(index).getLibOui(),
				this.sondageEdite.getQuestion(index).getLibNon()
		);
	}
 
	// Fonctions de l’éditeur de sondage
 
	public void setLibelleSondage (String _lsond)
	{
		this.sondageEdite.setLibSondage(_lsond);
	}
 
	public void controleurSauvegarderSondage ()
	{
		if (this.ves.getTitreSondage().isEmpty())
		{
			JOptionPane.showMessageDialog(this.ves, "Il faut saisir le nom du sondage !", "Erreur titre", JOptionPane.ERROR_MESSAGE);
		}
		else
		{
			int option = JOptionPane.showConfirmDialog(this.ves, "Voulez vous valider l'enregistrement du sondage '"+this.ves.getTitreSondage()+"'");
			if (option == 0)
			{
				boolean ok = appli.persistance.GestionSauvegardes.enregistreSondage(this.ves.getTitreSondage(), this.sondageEdite);
				if (ok)
				{
					JOptionPane.showMessageDialog(this.ves, "Enregistrement effectué avec succès !", "Enregistrement ok", JOptionPane.INFORMATION_MESSAGE);
				}
				else
					JOptionPane.showMessageDialog(this.ves, "Erreur dans l'enregistrement !", "Erreur enregistrement", JOptionPane.ERROR_MESSAGE);
			}
		}
 
 
	}
 
	public void controleurChargerUnSondage  ()
	{
		int option = JOptionPane.showConfirmDialog(this.ves, "Voulez vous charger un sondage existant ?");
		if (option == 0)
		{
			this.sondageEdite = appli.persistance.GestionSauvegardes.chargeSondage(this.ves.getTitreSondage());
		}
	}
 
	public void controleurNouveauSondage  ()
	{
 
 
		int option = JOptionPane.showConfirmDialog(this.ves, "Voulez vous créer un nouveau sondage ?");
		if (option == 0)
		{
			VueEditionSondage pVes;
			pVes = new VueEditionSondage("Nouveau Sondage", this);
			this.ves.setVisible(false);
			pVes.setVisible(true);
		}
	}
 
	public void controleurSupprimerQuestion  (int _index)
	{
		int option = 0;		
		option = JOptionPane.showConfirmDialog(this.ves, "Voulez vous valider la suppression ?");
		if (option == 0) // On récupère la valeur retourné lors de la validation  
		{
			boolean ok = this.sondageEdite.removeQuestion(this.sondageEdite.getQuestion(_index)); // On test si le sondage est bien supprimé ou pas
			if (ok) // si bien supprimé alors on affiche une boite de dialogue pour information et on fait une maj de la vue
			{
				JOptionPane.showMessageDialog(this.ves, "Question supprimée avec succès !", "Suppression ok", JOptionPane.INFORMATION_MESSAGE);
				this.ves.majVueEditionSondage();
			}
			else // sinon message d'erreur
				JOptionPane.showMessageDialog(this.ves,"Erreur dans la suppression", "Erreur suppression", JOptionPane.ERROR_MESSAGE);
		}		
	}
 
	public void controleurAjouterQuestion ()
	{
		this.veq = new VueEditionQuestion(this.ves,"Saisie d'une question", this);
		this.ves.majVueEditionSondage();
	}
 
	public void controleurArreterEditionSondage  () 
	{
		// ...
 
		this.ves = null;
	}
 
	public void controleurTesterQBDepuisEditeurSondage  (QuestionBinaire _quest)
	{
		this.vqb = new VueQuestionBinaire(this.ves,"Test d'une question", _quest);
		this.vqb.setVisible(true);
		this.ves.majVueEditionSondage();
 
		}
 
 
 
	// Fonctions de l’éditeur de question
 
	public void controleurTesterQBEnEdition  (QuestionBinaire _quest)
	{
		this.vqb = new VueQuestionBinaire (this.ves,"Test d'une question", _quest);
		this.ves.majVueEditionSondage();
		this.vqb.setVisible(true);
	}
 
	public void  controleurEnregistrerQB  (QuestionBinaire q)
	{
		int option = JOptionPane.showConfirmDialog(this.veq, "Voulez vous valider l'ajout de la question ?");
		if (option == 0)
		{
			boolean ok = this.sondageEdite.addQuestion(q);
			if (ok)
			{
				JOptionPane.showMessageDialog(this.ves, "Question ajoutée avec succès !", "Ajout ok", JOptionPane.INFORMATION_MESSAGE);
				this.ves.majVueEditionSondage();			
			}
			else
				JOptionPane.showMessageDialog(this.ves, "Erreur dans l'ajout", "Erreur ajout", JOptionPane.ERROR_MESSAGE);
 
		}
	}
 
	public void controleurQuitterEditeurQB () 
	{
	}		
}
ghoriu est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 15h08   #8
ghoriu
Invité de passage
 
Homme
Toulouse
Inscription : décembre 2012
Messages : 8
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Toulouse
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : décembre 2012
Messages : 8
Points : 0
Points : 0
Et pour les erreurs j'ai sa :
Code :
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
Exception occurred during event dispatching:
java.lang.NullPointerException
	at v_edition.Enregistrer.actionPerformed(VueQuestionBinaire.java:108)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$000(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$2.run(Unknown Source)
	at java.awt.EventQueue$2.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.Dialog$1.run(Unknown Source)
	at java.awt.Dialog$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.Dialog.show(Unknown Source)
	at java.awt.Component.show(Unknown Source)
	at java.awt.Component.setVisible(Unknown Source)
	at java.awt.Window.setVisible(Unknown Source)
	at java.awt.Dialog.setVisible(Unknown Source)
	at c_controleurs.ControleurEditeurSondage.controleurTesterQBDepuisEditeurSondage(ControleurEditeurSondage.java:152)
	at v_edition.EcouteurTest.actionPerformed(VueEditionSondage.java:200)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$000(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$2.run(Unknown Source)
	at java.awt.EventQueue$2.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
ghoriu est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 15h08   #9
tchize_
Expert Confirmé Sénior
 
Avatar de tchize_
 
Homme
Responsable de service informatique
Inscription : avril 2007
Messages : 18 280
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : Belgique

Informations professionnelles :
Activité : Responsable de service informatique
Secteur : Service public

Informations forums :
Inscription : avril 2007
Messages : 18 280
Points : 32 756
Points : 32 756
Envoyer un message via MSN à tchize_ Envoyer un message via Skype™ à tchize_
Il manque ton erreur complète pour s'y retrouver.
__________________
⥀⥁ Чиз faq java, cours java, javadoc. Pensez à et
Laisse entrer le jour après une nuit sombre. Si tu es toujours là, tu n'es pas faite pour mourir.
tchize_ est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 18h24   #10
ghoriu
Invité de passage
 
Homme
Toulouse
Inscription : décembre 2012
Messages : 8
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Toulouse
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : décembre 2012
Messages : 8
Points : 0
Points : 0
Je viens de la donner juste après mon code
ghoriu est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 18h27   #11
Heimdal
Membre chevronné
 
Avatar de Heimdal
 
Inscription : avril 2006
Messages : 549
Détails du profil
Informations forums :
Inscription : avril 2006
Messages : 549
Points : 637
Points : 637
Salut,

ves est null
Heimdal est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 27/12/2012, 21h42   #12
ghoriu
Invité de passage
 
Homme
Toulouse
Inscription : décembre 2012
Messages : 8
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Toulouse
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : décembre 2012
Messages : 8
Points : 0
Points : 0
Quelle classe s'il te plait ?
ghoriu est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 22h58   #13
tchize_
Expert Confirmé Sénior
 
Avatar de tchize_
 
Homme
Responsable de service informatique
Inscription : avril 2007
Messages : 18 280
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : Belgique

Informations professionnelles :
Activité : Responsable de service informatique
Secteur : Service public

Informations forums :
Inscription : avril 2007
Messages : 18 280
Points : 32 756
Points : 32 756
Envoyer un message via MSN à tchize_ Envoyer un message via Skype™ à tchize_
assez étonnament, celle que tu utilise en v_edition.Enregistrer.actionPerformed(VueQuestionBinaire.java:108)
__________________
⥀⥁ Чиз faq java, cours java, javadoc. Pensez à et
Laisse entrer le jour après une nuit sombre. Si tu es toujours là, tu n'es pas faite pour mourir.
tchize_ est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 29/12/2012, 17h19   #14
ghoriu
Invité de passage
 
Homme
Toulouse
Inscription : décembre 2012
Messages : 8
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Toulouse
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : décembre 2012
Messages : 8
Points : 0
Points : 0
Excuse mec mais fait pas genre tu avais trouvé sa dès le début, ya un mec il arrive 2 secondes après il trouve, viens pas faire le mec qui savait depuis le début et qui disait rien.
En tout cas merci pour vos réponses
ghoriu est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 01h07.


 
 
 
 
Partenaires

Hébergement Web