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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
| package gestionétudiant;
import java.awt.*;
import java.awt.event.ActionListener;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.awt.event.*;
import java.util.Vector;
import javax.swing.*;
public class Interfacee extends JFrame implements ActionListener {
gestionStagiaire1 A=new gestionStagiaire1();
private JMenuBar bar = new JMenuBar();
:cry:private JMenu fichier = new JMenu("Fichier");
private JMenuItem ajouté = new JMenuItem("Ajout");
private JMenuItem affiché= new JMenuItem("Affichage");
private JMenuItem quitté = new JMenuItem("Quitter");
private JMenuItem modifié = new JMenuItem("Modifier");
private JLabel numéro_inscription=new JLabel("numéro inscription ");
private JLabel nom=new JLabel("nom ");
private JLabel prénom=new JLabel("prénom");
private JLabel datenaissance =new JLabel("date de naissance ");
private JLabel sexe=new JLabel("sexe ");
String []listsexe={"masculin","féminin"};
private JComboBox list =new JComboBox(listsexe);
private JLabel module=new JLabel("Module ");
Integer []listmodule={1,2,3,4,5,6,7,8,9,10};
private JComboBox list1 =new JComboBox(listmodule);
private JLabel note =new JLabel("note ");
private JTextField numéro_inscription1=new JTextField(4);
private JTextField nom1=new JTextField(15);
private JTextField prénom1=new JTextField(15);
private JTextField datenaissance1=new JTextField(12);
private JTextField note1=new JTextField(4);
private JButton ajouter=new JButton("Ajouter");
private JButton supprimer=new JButton("Supprimer");
private JButton rechercher=new JButton("Rechercher");
private JButton modifier=new JButton("Modifier");
private JButton quitter=new JButton("Quitter");
private JButton effacer=new JButton("effacer");
private CardLayout card=new CardLayout();
private JComboBox combo = new JComboBox();
static Vector v =new Vector();
private JTextArea txt= new JTextArea();
private JScrollPane jScrollPane1 = new JScrollPane(txt);
private JLabel Numéro22= new JLabel("Numéro d'inscription :");
private JLabel Nom22 = new JLabel("NOM <new> :");
private JLabel Prénom22 = new JLabel("Prénom <new> :");
private JLabel datenaissance22 =new JLabel("date de naissance <new> : ");
private JLabel sexe22=new JLabel("sexe <new> : ");
private JLabel module22=new JLabel("Module <new> : ");
private JLabel note22 =new JLabel("note <new> : ");
private JTextField mod_nom = new JTextField();
private JTextField mod_prénom = new JTextField();
private JTextField mod_datenaissance = new JTextField();
private JTextField mod_note = new JTextField();
private JPanel fenetre=new JPanel();
private JPanel ajout=new JPanel();
private JPanel affichage=new JPanel();
private JPanel modification=new JPanel();
private JPanel p= new JPanel();
private JPanel p1=new JPanel();
private JPanel p2=new JPanel();
private JPanel p3=new JPanel();
private JPanel p4=new JPanel();
private JPanel p5=new JPanel();
private JPanel p6= new JPanel();
private JPanel p7= new JPanel();
private JPanel p8= new JPanel();
public Interfacee(){
try{
ObjectInputStream in = new ObjectInputStream(new FileInputStream("c:\\fichier.txt"));
v=(Vector) in.readObject();
in.close();
}catch(Exception ee){}
setTitle("gestion des stagiaires");
setBounds(600,600,600,600);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
combo.addActionListener(this);
ajout.setLayout(null);
ajout.add(numéro_inscription).setBounds(88, 170, 167, 30);
ajout.add(numéro_inscription1).setBounds(230, 170, 167, 30);
ajout.add(nom). setBounds(88, 110, 167, 30);
ajout.add(nom1). setBounds(230, 110, 167, 30);
ajout.add(prénom). setBounds(88, 170, 167, 30);
ajout.add(prénom1). setBounds(230, 170, 167, 30);
ajout.add(datenaissance). setBounds(88, 220, 167, 30);
ajout.add(datenaissance1).setBounds(230, 220, 167, 30);
ajout.add(sexe). setBounds(88, 270, 167, 30);
ajout.add(list). setBounds(230, 270, 167, 30);
ajout.add(module). setBounds(88, 270, 167, 30);
ajout.add(list1). setBounds(230, 270, 167, 30);
ajout.add(note). setBounds(88, 270, 167, 30);
ajout.add(note1). setBounds(230, 270, 167, 30);
ajout.add(ajouter). setBounds(150,400,167,30);
ajouter.addActionListener(this);
setJMenuBar(bar);
bar.add(fichier);
fichier.add(ajouté); ajouté.addActionListener(this);
fichier.add(affiché); affiché.addActionListener(this);
fichier.add(quitté); quitté.addActionListener(this);
fichier.add(modifié); modifié.addActionListener(this);
affichage.setLayout(null);
affichage.add(txt).setBounds(new Rectangle(10,10,450,400));
fenetre.add(ajout);
fenetre.add(affichage);
fenetre.add(modification);
add(fenetre);
fenetre.setLayout(card);
modification.setLayout(null);
modification.add(Numéro22). setBounds(88,120,167,30);
modification.add(combo). setBounds(230,120,167,30);
modification.add(Nom22). setBounds(88, 170, 167, 30);
modification.add(mod_nom). setBounds(230, 170, 167, 30);
modification.add(Prénom22). setBounds(88, 170, 167, 30);
modification.add(mod_prénom). setBounds(230, 170, 167, 30);
modification.add(datenaissance22). setBounds(88, 220, 167, 30);
modification.add(mod_datenaissance). setBounds(230, 220, 167, 30);
modification.add(sexe22). setBounds(88, 270, 167, 30);
modification.add(list). setBounds(230, 270, 167, 30);
modification.add(module22). setBounds(88, 270, 167, 30);
modification.add(list1). setBounds(230, 270, 167, 30);
modification.add(note22). setBounds(88, 270, 167, 30);
modification.add(mod_note). setBounds(230, 270, 167, 30);
modification.add(modifier). setBounds(150,400,167,30);
modifier.addActionListener(this);
p.setLayout(new GridLayout(10,1));
p.add(p1);
p1.add(numéro_inscription);
p1.add(numéro_inscription1);
p.add(p2);
p2.add(nom);
p2.add(nom1);
p.add(p3);
p3.add(prénom);
p3.add(prénom1);
p.add(p4);
p4.add(datenaissance);
p4.add(datenaissance1);
p.add(p5);
p5.add(sexe);
p5.add(list);
p.add(p6);
p6.add(module);
p6.add(list1);
p.add(p7);
p7.add(note);
p7.add(note1);
p.add(p8);
p8.add(ajouter); ajouter.addActionListener(this);
p8.add(supprimer);supprimer.addActionListener(this);
p8.add(rechercher);rechercher.addActionListener(this);
p8.add(modifier);modifier.addActionListener(this);
p8.add(quitter);quitter.addActionListener(this);
p8.add(effacer);effacer.addActionListener(this);
add(p);}
public void actionPerformed(ActionEvent e){
Object o=e.getSource();
if (o==ajouté){
A.ajouter_stagiaire(Integer.parseInt(numéro_inscription1.getText()), nom1.getText(), prénom1.getText(), list.getToolTipText(), datenaissance.getText(), Integer.parseInt(list1.getToolTipText()), Float.parseFloat(note1.getText()));
setTitle("Ajout");
//this.card.show(this.fenetre, "ajouté");
try{
ajout.setVisible(true);
affichage.setVisible(false);
modification.setVisible(false);
}catch(Exception ee){System.out.println(ee.getMessage() );}
}
// if(e.getSource()==ajouter) {
// A.ajouter_stagiaire(Integer.parseInt(numéro_inscription1.getText()), nom1.getText(), prénom1.getText(), list.getToolTipText(), datenaissance.getText(), Integer.parseInt(list1.getToolTipText()), Float.parseFloat(note1.getText()));
//}
if(o==quitter){
try
{
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("c:\\fichier.txt"));
out.writeObject(v);
out.close();
}catch(Exception ee){}
System.exit(0);
}
if(e.getSource()==quitté){
System.exit(0);
}
if((e.getSource()==modifier)){
A.modifier_stagiaire(Integer.parseInt(numéro_inscription1.getText()), nom1.getText(), prénom1.getText(), list.getToolTipText(), datenaissance.getText(),Integer.parseInt(list1.getToolTipText()),Float.parseFloat(note1.getText()) );
ajout.setVisible(false);
affichage.setVisible(false);
modification.setVisible(true);
combo.removeAll();
for (int i=0 ; i<v.size();i++)
combo.addItem( ((Stagiaire)v.elementAt(i)).getNumeroinscription());
}
if(o==combo){
A.modifier_stagiaire(Integer.parseInt(numéro_inscription1.getText()), nom1.getText(), prénom1.getText(), list.getToolTipText(), datenaissance.getText(),Integer.parseInt(list1.getToolTipText()),Float.parseFloat(note1.getText()) );
int var=(Integer.valueOf(combo.getSelectedItem().toString()));
for(int i=0;i<v.size();i++){
Stagiaire a= (Stagiaire)v.elementAt(i);
if(a.getNumeroinscription()==var) {
mod_nom.setText(a.getNom());
mod_prénom.setText(""+a.getPrenom());
mod_datenaissance.setText(""+a.getDatenaiss());
mod_note.setText(""+a.getNote());
}
}
}
if(o==affiché ){
ajout.setVisible(false);
affichage.setVisible(true);
modification.setVisible(false);
try{
txt.setText("");
for(int i =0;i<v.size();i++){
txt.append( ((Stagiaire)v.elementAt(i)).toString()+"\n");
}
}catch (Exception y){JOptionPane.showMessageDialog(this,"La liste des Stagiaires est vide");}
}
if((e.getSource()==supprimer)){
A.supprimer_stagiaire(Integer.parseInt(numéro_inscription1.getText()));
numéro_inscription1.setText("");
nom1.setText("");
prénom1.setText("");
datenaissance1.setText("");
note1.setText("");
}
if ((e.getSource()==effacer)){
numéro_inscription1.setText("");
nom1.setText("");
prénom1.setText("");
datenaissance1.setText("");
note1.setText("");
}
}
public static void main(String[] args) {
new Interfacee();
}
} |
Partager