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 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
| package fenetre;
import javax.swing.*;
import com.toedter.calendar.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.TitledBorder;
import color.*;
import controle.*;
import java.net.MalformedURLException;
import model.*;
import service.*;
import java.rmi.*;
import java.util.*;
import java.util.logging.*;
public class Ajout extends JPanel {
private static final long serialVersionUID = 1L;
private TraiteBtn btn;
private TraiteMenu men;
private Model model;
private Acceuil Acc;
ArrayList<String> data = new ArrayList<String>();
InterfaceS InterP;
Cursor sablier = new Cursor(Cursor.HAND_CURSOR);
ResourceBundle bundle = ResourceBundle.getBundle("ressources/Langue"); // NOI18N
public Ajout(){
try {
//Déclaration des panels
PChamp = new JPanel();
PBouton = new JPanel();
Panel1 = new JPanel();
Panel2 = new JPanel();
Panel3 = new JPanel();
Panel4 = new JPanel();
Panel5 = new JPanel();
Panel6 = new JPanel();
Panel7 = new JPanel();
//Déclaration des labels
LMat = new JLabel();
LCiv = new JLabel();
LNom = new JLabel();
LPrenom = new JLabel();
Lmatr = new JLabel();
LFct = new JLabel();
LPhone = new JLabel();
LMobile = new JLabel();
LMail = new JLabel();
LDaten = new JLabel();
Llieu = new JLabel();
LLog = new JLabel();
LPwd = new JLabel();
LPro = new JLabel();
//Déclaration des zones de saisie de texte
TMat = new JTextField(10);
TNom = new JTextField(10);
TPrenom = new JTextField(10);
TMob = new JTextField(10);
TMail = new JTextField(10);
TPhone = new JTextField(10);
TLieu = new JTextField(10);
TLog = new JTextField(10);
TPwd = new JTextField(10);
//Déclaration des combo box
Cciv = new JComboBox();
Cmatr = new JComboBox();
Cfct = new JComboBox();
Cpro = new JComboBox();
//Déclaration des boutons
BtAdd = new JButton(bundle.getString("ADD"));
BtAdd.setForeground(new Couleur().COULEUR_TEXTE_BOUTON);
BtAdd.setFont(new Font("Verdana", 1, 12));
BtAdd.setCursor(sablier);
BtMod = new JButton(bundle.getString("MODIFIED"));
BtMod.setForeground(new Couleur().COULEUR_TEXTE_BOUTON);
BtMod.setFont(new Font("Verdana", 1, 12));
BtMod.setCursor(sablier);
BtDel = new JButton(bundle.getString("DELETE"));
BtDel.setForeground(new Couleur().COULEUR_TEXTE_BOUTON);
BtDel.setFont(new Font("Verdana", 1, 12));
BtDel.setCursor(sablier);
BtAc = new JButton(bundle.getString("REFRESH"));
BtAc.setForeground(new Couleur().COULEUR_TEXTE_BOUTON);
BtAc.setFont(new Font("Verdana", 1, 12));
BtAc.setCursor(sablier);
//Déclaration d'un champ de saisie de la date
date = new JDateChooser("dd/MM/yyyy", "##/##/####", '-');
//Déclaration et instantiation des classe de controle et de model
btn = new TraiteBtn(this, model);
//Ajout l'instance de la classe TraiteBtn aux boutons
BtAdd.addActionListener(btn);
BtMod.addActionListener(btn);
BtDel.addActionListener(btn);
BtAc.addActionListener(btn);
//Place le curseur dans la zone de saisie du matricule
Acc.addWindowListener(new WindowAdapter() {
@Override
public void windowActivated(WindowEvent event) {
TMat.requestFocusInWindow();
}
});
LMat.setText(bundle.getString("MATRICULE")+" ");
LMat.setForeground(new Couleur().COULEUR_TEXTE);
LMat.setFont(new Font("Verdana", 1, 12));
TMat.setText(null);
TMat.setForeground(new Couleur().COULEUR_TEXTE);
TMat.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
TMat.setFont(new Font("Verdana", 1, 12));
LMat.setLabelFor(TMat);
LCiv.setText(bundle.getString("CIVILITE")+" ");
LCiv.setForeground(new Couleur().COULEUR_TEXTE);
LCiv.setFont(new Font("Verdana", 1, 12));
Cciv.setModel(new DefaultComboBoxModel(new String[] { "Item 1", "Item 2" }));
LCiv.setLabelFor(Cciv);
Cciv.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
Cciv.setFont(new Font("Verdana", 1, 12));
Cciv.setForeground(new Couleur().COULEUR_TEXTE);
Panel1.setLayout(new FlowLayout(FlowLayout.LEFT));
Panel1.setOpaque(false);
Panel1.add(LMat);
Panel1.add(TMat);
Panel1.add(LCiv);
Panel1.add(Cciv);
LNom.setText(bundle.getString("NOM")+" ");
LNom.setForeground(new Couleur().COULEUR_TEXTE);
LNom.setFont(new Font("Verdana", 1, 12));
TNom.setText(null);
TNom.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
TNom.setFont(new Font("Verdana", 1, 12));
TNom.setForeground(new Couleur().COULEUR_TEXTE);
LNom.setLabelFor(TNom);
LPrenom.setText(bundle.getString("PRENOM")+" ");
LPrenom.setForeground(new Couleur().COULEUR_TEXTE);
LPrenom.setFont(new Font("Verdana", 1, 12));
TPrenom.setText(null);
TPrenom.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
TPrenom.setFont(new Font("Verdana", 1, 12));
TPrenom.setForeground(new Couleur().COULEUR_TEXTE);
LPrenom.setLabelFor(TPrenom);
Panel2.setLayout(new FlowLayout(FlowLayout.LEFT));
Panel2.setOpaque(false);
Panel2.add(LNom);
Panel2.add(TNom);
Panel2.add(LPrenom);
Panel2.add(TPrenom);
Lmatr.setText(bundle.getString("STATUT_MAT")+" ");
Lmatr.setForeground(new Couleur().COULEUR_TEXTE);
Cmatr.setModel(new DefaultComboBoxModel(new String[] { "Item 1", "Item 2"}));
Lmatr.setLabelFor(Cmatr);
Lmatr.setFont(new Font("Verdana", 1, 12));
Cmatr.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
Cmatr.setFont(new Font("Verdana", 1, 12));
Cmatr.setForeground(new Couleur().COULEUR_TEXTE);
LFct.setText(" "+bundle.getString("FONCTION")+" ");
LFct.setForeground(new Couleur().COULEUR_TEXTE);
Cfct.setModel(new DefaultComboBoxModel(new String[] { "Item 1", "Item 2"}));
LFct.setLabelFor(Cfct);
LFct.setFont(new Font("Verdana", 1, 12));
Cfct.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
Cfct.setFont(new Font("Verdana", 1, 12));
Cfct.setForeground(new Couleur().COULEUR_TEXTE);
Panel3.setLayout(new FlowLayout(FlowLayout.LEFT));
Panel3.setOpaque(false);
Panel3.add(Lmatr);
Panel3.add(Cmatr);
Panel3.add(LFct);
Panel3.add(Cfct);
LPhone.setText(bundle.getString("PHONE")+" ");
LPhone.setForeground(new Couleur().COULEUR_TEXTE);
LPhone.setFont(new Font("Verdana", 1, 12));
TPhone.setText(null);
TPhone.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
TPhone.setFont(new Font("Verdana", 1, 12));
TPhone.setForeground(new Couleur().COULEUR_TEXTE);
LPhone.setLabelFor(TPhone);
LMobile.setText(bundle.getString("MOBILE")+" ");
LMobile.setForeground(new Couleur().COULEUR_TEXTE);
LMobile.setFont(new Font("Verdana", 1, 12));
TMob.setText(null);
TMob.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
TMob.setFont(new Font("Verdana", 1, 12));
TMob.setForeground(new Couleur().COULEUR_TEXTE);
LMobile.setLabelFor(TMob);
Panel4.setLayout(new FlowLayout(FlowLayout.LEFT));
Panel4.setOpaque(false);
Panel4.add(LPhone);
Panel4.add(TPhone);
Panel4.add(LMobile);
Panel4.add(TMob);
LMail.setText(bundle.getString("MAIL")+" ");
LMail.setForeground(new Couleur().COULEUR_TEXTE);
LMail.setFont(new Font("Verdana", 1, 12));
TMail.setText(null);
TMail.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
TMail.setFont(new Font("Verdana", 1, 12));
TMail.setForeground(new Couleur().COULEUR_TEXTE);
LMail.setLabelFor(TMail);
LPro.setText(" "+bundle.getString("PROFIL")+" ");
LPro.setForeground(new Couleur().COULEUR_TEXTE);
LPro.setFont(new Font("Verdana", 1, 12));
Cpro.setModel(new DefaultComboBoxModel(new String[] { "Item 1", "Item 2"}));
Cpro.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
Cpro.setFont(new Font("Verdana", 1, 12));
Cpro.setForeground(new Couleur().COULEUR_TEXTE);
LPro.setLabelFor(Cpro);
Panel5.setLayout(new FlowLayout(FlowLayout.LEFT));
Panel5.setOpaque(false);
Panel5.add(LMail);
Panel5.add(TMail);
Panel5.add(LPro);
Panel5.add(Cpro);
LDaten.setText(bundle.getString("DATE_NAISS")+" ");
LDaten.setForeground(new Couleur().COULEUR_TEXTE);
LDaten.setFont(new Font("Verdana", 1, 12));
LDaten.setLabelFor(date);
date.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
date.setFont(new Font("Verdana", 1, 12));
date.setForeground(new Couleur().COULEUR_TEXTE);
Llieu.setText(bundle.getString("LIEU_NAISS"));
Llieu.setForeground(new Couleur().COULEUR_TEXTE);
Llieu.setLabelFor(TLieu);
Llieu.setFont(new Font("Verdana", 1, 12));
TLieu.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
TLieu.setFont(new Font("Verdana", 1, 12));
TLieu.setForeground(new Couleur().COULEUR_TEXTE);
TLieu.setText(null);
Panel6.setLayout(new FlowLayout(FlowLayout.LEFT));
Panel6.setOpaque(false);
Panel6.add(LDaten);
Panel6.add(date);
Panel6.add(Llieu);
Panel6.add(TLieu);
LLog.setText(bundle.getString("LOGIN")+" ");
LLog.setForeground(new Couleur().COULEUR_TEXTE);
LLog.setFont(new Font("Verdana", 1, 12));
TLog.setText(null);
TLog.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
TLog.setFont(new Font("Verdana", 1, 12));
TLog.setForeground(new Couleur().COULEUR_TEXTE);
LLog.setLabelFor(TLog);
LPwd.setText(" "+bundle.getString("PASSWORD")+" ");
LPwd.setForeground(new Couleur().COULEUR_TEXTE);
LPwd.setFont(new Font("Verdana", 1, 12));
TPwd.setText(null);
TPwd.setBackground(new Couleur().COULEUR_BACKGROUND_TEXTE_FIELD);
TPwd.setFont(new Font("Verdana", 1, 12));
TPwd.setForeground(new Couleur().COULEUR_TEXTE);
LPwd.setLabelFor(TPwd);
Panel7.setLayout(new FlowLayout(FlowLayout.LEFT));
Panel7.setOpaque(false);
Panel7.add(LLog);
Panel7.add(TLog);
Panel7.add(LPwd);
Panel7.add(TPwd);
PChamp.setLayout(new FlowLayout(FlowLayout.LEFT));
PChamp.setPreferredSize(new Dimension(515, 350));
PChamp.setBackground(new Couleur().COULEUR_BACKGROUND_BLOC);
PChamp.setBorder(BorderFactory.createTitledBorder(null, bundle.getString("INFO_USER"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Verdana", 3, 12), new Couleur().COULEUR_TITRE_BORDURE));
PChamp.add(Panel1);
PChamp.add(Panel2);
PChamp.add(Panel3);
PChamp.add(Panel4);
PChamp.add(Panel5);
PChamp.add(Panel6);
PChamp.add(Panel7);
PBouton.setLayout(new FlowLayout(FlowLayout.CENTER));
PBouton.setPreferredSize(new Dimension(515, 60));
PBouton.setBorder(BorderFactory.createTitledBorder(null, bundle.getString("ACTION"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Verdana", 3, 12), new Couleur().COULEUR_TITRE_BORDURE));
PBouton.setBackground(new Couleur().COULEUR_BACKGROUND_BLOC);
PBouton.add(BtAdd);
PBouton.add(BtMod);
PBouton.add(BtDel);
PBouton.add(BtAc);
panglo.setLayout(new FlowLayout(FlowLayout.RIGHT));
panglo.setBorder(new TitledBorder("Adresse du client"));
panglo.setPreferredSize(new Dimension(516, 410));
panglo.add(PChamp);
panglo.add(PBouton);
this.add(panglo, BorderLayout.CENTER);
}
catch(Exception e){
// e.printStackTrace();
}
chargerprofil();
chargerciv();
chargermat();
chargerfct();
}
private void chargerprofil(){
//---
try {
//---
InterP =(InterfaceS)Naming.lookup("rmi://localhost:1099/ServiceServeur");
data = InterP.getAllPro();
}
catch (NotBoundException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
catch (MalformedURLException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
catch (RemoteException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
//---
int nombre = data.size() - 1;
String[] ser = new String[nombre];
for(int i=0; i<nombre; i++) {
ser[i] = data.get(i+1);
}
Cpro.setModel(new javax.swing.DefaultComboBoxModel(ser));
}
private void chargerciv(){
//---
try {
//---
InterP =(InterfaceS)Naming.lookup("rmi://localhost:1099/ServiceServeur");
data = InterP.getAllCiv();
}
catch (NotBoundException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
catch (MalformedURLException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
catch (RemoteException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
//---
int nombre = data.size() - 1;
String[] ser = new String[nombre];
for(int i=0; i<nombre; i++) {
ser[i] = data.get(i+1);
}
Cciv.setModel(new javax.swing.DefaultComboBoxModel(ser));
}
private void chargermat(){
//---
try {
//---
InterP =(InterfaceS)Naming.lookup("rmi://localhost:1099/ServiceServeur");
data = InterP.getAllMat();
}
catch (NotBoundException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
catch (MalformedURLException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
catch (RemoteException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
//---
int nombre = data.size() - 1;
String[] ser = new String[nombre];
for(int i=0; i<nombre; i++) {
ser[i] = data.get(i+1);
}
Cmatr.setModel(new javax.swing.DefaultComboBoxModel(ser));
}
private void chargerfct(){
//---
try {
//---
InterP =(InterfaceS)Naming.lookup("rmi://localhost:1099/ServiceServeur");
data = InterP.getAllFct();
}
catch (NotBoundException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
catch (MalformedURLException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
catch (RemoteException exc) {
Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, exc);
}
//---
int nombre = data.size() - 1;
String[] ser = new String[nombre];
for(int i=0; i<nombre; i++) {
ser[i] = data.get(i+1);
}
Cfct.setModel(new javax.swing.DefaultComboBoxModel(ser));
}
//Création des combo box
public JComboBox Cciv, Cmatr, Cfct, Cpro;
//Création des Label
private JLabel LMat, LDaten, LCiv, LNom, LPrenom, Lmatr, LFct, LPhone,
LMobile,LMail, Llieu, LLog, LPwd, LPro;
//Création des panels
private JPanel PChamp, PBouton, Panel1, Panel2, Panel3, Panel4, Panel5,
Panel6, Panel7, panglo;
//Création des zones de saise de texte
public JTextField TMat, TNom, TPrenom, TMob, TMail, TPhone, TLieu, TLog,
TPwd;
//Création des boutons
public JButton BtAdd, BtMod, BtDel, BtAc;
//Création d'un champs de saisie de la date
public JDateChooser date;
} |
Partager