voici mon code java je veux resoudre l'exercices qui dit:
definir des ecouteurs pour les boutton
<| afficher la fiche des information du premier employee enregistre
enregistrer: sauvgarder la fiche d'un employee en cours dans array list
precedent:affiche la fiche precedente d'un employee
suivant :affiche la fiche suivante d'un employee
supprimer:supprime employe selectionee
ajouter:ajouter un nouvel employee
annuler:annuler les info saisit et quitter le formulaire
|>afficher la fiche des info du dernier employee enregistre
associer des ecouteurs pour la recherche par nom ,par date de naissance ,par etat civil merci de m'aider et de me corriger
voici le code que j'ai proposer
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
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Vector;
 
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
 
 
 
public class infoEmployee extends JFrame  implements ActionListener{
	JPanel panne = new JPanel();
	Vector v1= new Vector();
	Vector v2= new Vector();
	Vector v3= new Vector();
	Vector v4= new Vector();
	ArrayList<infoEmployee> emp =new ArrayList<>();
	static int  j=0;
	int iterator=j;
 
	JPanel niveau1 =new JPanel();
	JLabel nom =new JLabel("Nom:");
	JTextField nomText = new JTextField(20);
	JPanel niveau2 =new JPanel();
	JLabel dateNaissance =new JLabel("Date de naissance:");
	JComboBox  jour = new JComboBox(v1);
 
	String[] m = {"janvier","fevrier","mars","avril","mai","juin","juillet","aout","september","octobre","novembre","decembre"};
	JComboBox <String> mois = new JComboBox(m); 
	JComboBox annee = new JComboBox(v2);   
 
	JPanel niveau4 =new JPanel();
	JLabel nbE =new JLabel("nombre d'enfants:");
	JPanel niveau5 =new JPanel();
	JLabel dateRecrutement =new JLabel("Date de recrutement:");
	JPanel niveau3 =new JPanel();
	JLabel etatCivil =new JLabel("Etat Civil:");
	String [] e= {"célibataire","marié(e)","veuf(ve)","divorcé(e)"};
	JComboBox etat = new JComboBox(e);
	JComboBox nombreE = new JComboBox(v3);
	JComboBox jourR = new JComboBox(v1);   
	JComboBox moisR = new JComboBox(m);
	JComboBox anneeR = new JComboBox(v2);   
 
	JPanel niveau6 =new JPanel();
	JButton b1=new JButton("<|");
	JButton b2=new JButton("Enregistrer");
	JButton b3=new JButton("Précédent");
	JButton b4=new JButton("Suivant");
	JButton b5=new JButton("Supprimer");
	JButton b6=new JButton("Ajouter");
	JButton b7=new JButton("nnuler");
	JButton b8=new JButton("|>");
 
	JPanel niveau0=new JPanel();
	JButton rechercher=new JButton("rechercher");
 
	JCheckBox parNom=new JCheckBox("nom");
	JTextField rechN=new JTextField(10);
 
	JCheckBox parDate =new JCheckBox("date de naissance");
 
	JComboBox jourRR = new JComboBox(v1);   
	JComboBox moisRR= new JComboBox(m);
	JComboBox anneeRR = new JComboBox(v2);  
 
 
 
 
	JCheckBox parEtat =new JCheckBox("Etat civil");
	JTextField rechE=new JTextField(10);
	JPanel panneauGlobal =new JPanel();
	public infoEmployee(){
 
		setTitle("infoEmployeé");
		JPanel p2=new JPanel();
		JComboBox  rechJ = new JComboBox(v1);
		JComboBox <String> rechM= new JComboBox(m); 
		JComboBox rechA = new JComboBox(v2); 
		JPanel date=new JPanel();
        date.add(rechJ);
        date.add(rechM);
        date.add(rechA);
		p2.add(parDate);
		p2.add(date);
		JPanel p1=new JPanel();
		p1.add(parNom);
		p1.add(rechN);
		JPanel p3=new JPanel();
		p3.add(parEtat);
		p3.add(rechE);
		niveau0.setLayout(new BoxLayout(niveau0,BoxLayout.Y_AXIS));
		niveau0.add(p1);
		niveau0.add(p2);
		niveau0.add(p3);
		niveau0.add(rechercher);
 
 
 
 
 
		niveau1.add(nom);
		niveau1.add(nomText);
 
 
		niveau2.add(dateNaissance);
		String j;
		for(int i=1;i<32;i++){
			v1.add(i+"");
 
		}
 
 
		for(int i=1950;i<2051;i++){
			v2.add( i+"");
 
		}
 
		niveau2.add(jour);
		niveau2.add(mois);
		niveau2.add(annee);
 
 
		niveau3.add(etatCivil);
 
		niveau3.add(etat);
 
		niveau4.add(nbE);
		for(int i=0;i<10;i++){
			v3.add(i+"");
		}
 
 
		niveau4.add(nombreE);
 
 
		niveau5.add(dateRecrutement);
 
 
		niveau5.add(jourR);
		niveau5.add(moisR);
		niveau5.add(anneeR);
 
 
		niveau6.setLayout(new FlowLayout());
		niveau6.add(b1);niveau6.add(b2);niveau6.add(b3);niveau6.add(b4);niveau6.add(b5);niveau6.add(b6);
		niveau6.add(b7);niveau6.add(b8);
 
 
 
		panne.setLayout(new BoxLayout(panne,BoxLayout.Y_AXIS));
 
		panne.add(niveau1);
		panne.add(niveau2);
		panne.add(niveau3);
		panne.add(niveau4);
		panne.add(niveau5);
		panne.add(niveau6);
		panne.add(niveau0);
 
 
		panneauGlobal.setLayout(new BorderLayout());
 
		panneauGlobal.add(panne,BorderLayout.EAST);
 
		getContentPane().add(panneauGlobal);
		setVisible(true);
		setLocationRelativeTo(null);
		setSize(560,500);
 
		b1.addActionListener(this);
		b2.addActionListener(this);
		b3.addActionListener(this);
		b4.addActionListener(this);
		b5.addActionListener(this);
		b6.addActionListener(this);
		b7.addActionListener(this);
		b8.addActionListener(this);
		rechercher.addActionListener(this);
	}
	public static void main(String[] args) {
		new infoEmployee();
	}
 
 
 
	@Override
	public void actionPerformed(ActionEvent e) {
 
		// TODO Auto-generated method stub
		JButton s=(JButton)e.getSource();
		if (s==b7){
			System.exit(1);
		}
		if (s==b2){
			emp.add(j,this);
 
 
 
		}
		if (s==b1){
 
			emp.get(0).setVisible(true);
		}
		if (s==b8){
			this.setVisible(false);
			emp.get(emp.size()-1).setVisible(true);
		}
		if (s==b6){
			j++;
			this.setVisible(false);
			infoEmployee empno = new infoEmployee();
			empno.setVisible(true);
			System.out.println("employee ajoute");
 
 
		}
		if (s==b3){
			this.setVisible(false);
			emp.get(iterator-1).setVisible(true);
		}
		if (s==b4){
			emp.get(iterator + 1).setVisible(true);
			this.setVisible(false);
		}
 
		if (s==b5){
 
			this.setVisible(false);
			emp.remove(j);
			emp.get(iterator-1).setVisible(true);
 
		}
 
		if (s==rechercher) {
			if(parNom.isSelected()) {
 
				for (infoEmployee e1:emp) {
					if (e1.nomText.getText()==rechN.getText()){
						this.setVisible(false);
						emp.get(e1.iterator).setVisible(true);
					}
				}
 
//			}else if (parDate.isSelected()){
//
//				for (infoEmployee e1:emp) {
//					if (e1.jourR.getSelectedItem().toString()==rechT.getText()){
//						this.setVisible(false);
//						emp.get(e1.iterator).setVisible(true);
//					}
//				}
//
//			}
 
 
 
		}else if (parEtat.isSelected()){
			for (infoEmployee e1:emp) {
				if (e1.etat.getSelectedItem().toString()==rechE.getText()){
					this.setVisible(false);
					emp.get(e1.iterator).setVisible(true);
				}
			}
 
		}}}}