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
|
public class PanelEmploye extends JPanel implements Observer {
private AppliModel monModel; // Modele
private AppliControleur monControler; // Controleur
private String[] columnNames = { "N° Employé", "Nom", "Hebdo", "Service" };
private JButton JButtonConsulterDetailEmp;
private JButton JButtonAjouterEmpl;
private JButton JButtonSuppEmpl;
private JButton JButtonChangeAffect;
private JButton JButtonChangeHebdo;
private JTable listeEmploye;
private Object[][] data = null;
private GridBagLayout grid;
private GridBagConstraints con;
public PanelEmploye(AppliControleur monC, AppliModel monM) {
monControler = monC; // Initialisation du controler
monModel = monM; // Initialisation du modele
monModel.addObserver(this);
grid = new GridBagLayout();
con = new GridBagConstraints();
this.setLayout(grid);
this.setSize(700, 500);
this.setBackground(new Color(255, 255, 255));
Contrainte.donnerContrainte(con, 0, 0, 2, 1, 100, 0,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,new Insets(20, 20, 20, 20));
JLabel titre = new JLabel("<html><u>Veuillez sélectionner un employé dans la liste, afin de pouvoir effectuer une actions:</u></html>");
titre.setFont(new java.awt.Font("Tahoma", 1, 12));
this.add(titre, con);
titre.setAutoscrolls(true);
Contrainte.donnerContrainte(con, 1, 1, 1, 1, 0, 0,GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,new Insets(0, 30, 40, 30));
JButtonAjouterEmpl = new JButton("Ajouter employé");
this.add(JButtonAjouterEmpl, con);
JButtonAjouterEmpl.addActionListener(monControler);
Contrainte.donnerContrainte(con, 1, 2, 1, 1, 0, 0,GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,new Insets(0, 30, 40, 30));
JButtonConsulterDetailEmp = new JButton("Voir détails employé");
this.add(JButtonConsulterDetailEmp, con);
Contrainte.donnerContrainte(con, 1, 3, 1, 1, 0, 0,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,new Insets(0, 30, 40, 30));
JButtonSuppEmpl = new JButton("Supprimer employé");
this.add(JButtonSuppEmpl, con);
JButtonSuppEmpl.addActionListener(monControler);
Contrainte.donnerContrainte(con, 1, 4, 1, 1, 0, 0,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,new Insets(0, 30, 40, 30));
JButtonChangeAffect = new JButton("Changer d'affectation");
this.add(JButtonChangeAffect, con);
JButtonChangeAffect.addActionListener(monControler);
Contrainte.donnerContrainte(con, 1, 5, 1, 1, 0, 0,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,new Insets(0, 30, 40, 30));
JButtonChangeHebdo = new JButton("Changer Hebdo");
this.add(JButtonChangeHebdo, con);
}
public void update(Observable o, Object arg) {
if (arg.equals("employe")) {
System.out.println("employe");
data = monModel.getListeEmploye();
Contrainte.donnerContrainte(con, 0, 1, 1, 5, 0, 100,GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,new Insets(0, 20, 30, 0));
listeEmploye = new JTable(data, columnNames);
listeEmploye.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
listeEmploye.setPreferredScrollableViewportSize(new Dimension(420, 300));
JScrollPane scrollPane = new JScrollPane(listeEmploye);
this.add(scrollPane, con);
listeEmploye.addMouseListener(monControler);
this.updateUI();
}
}
} |
Partager