From 466a562f23c60ab865b4b877f3ad22cfba82a302 Mon Sep 17 00:00:00 2001 From: saaya-code Date: Sun, 24 Mar 2024 02:19:07 +0100 Subject: [PATCH] finished formation, and made the ajout etudiant interface 1st version --- src/ExercicesTP/CRUD/EtudiantDAO.java | 30 ++++++++++ src/ExercicesTP/IHM/IHMAjoutEtudiant.java | 72 +++++++++++++++++++++++ src/ExercicesTP/IHM/Principale.java | 9 +++ 3 files changed, 111 insertions(+) create mode 100644 src/ExercicesTP/CRUD/EtudiantDAO.java create mode 100644 src/ExercicesTP/IHM/IHMAjoutEtudiant.java diff --git a/src/ExercicesTP/CRUD/EtudiantDAO.java b/src/ExercicesTP/CRUD/EtudiantDAO.java new file mode 100644 index 0000000..dedb71b --- /dev/null +++ b/src/ExercicesTP/CRUD/EtudiantDAO.java @@ -0,0 +1,30 @@ +package ExercicesTP.CRUD; +import ExercicesTP.Etudiant; +import ExercicesTP.interfaces.EtudiantDaoCRUD; +public class EtudiantDAO implements EtudiantDaoCRUD{ + + @Override + public void addEtudiant(Etudiant etudiant) { + + } + + @Override + public void deleteEtudiant(int id) { + + } + + @Override + public void updateEtudiant(Etudiant etudiant) { + + } + + @Override + public Etudiant getEtudiant(int id) { + return null; + } + + @Override + public Etudiant[] getAllEtudiants() { + return new Etudiant[0]; + } +} diff --git a/src/ExercicesTP/IHM/IHMAjoutEtudiant.java b/src/ExercicesTP/IHM/IHMAjoutEtudiant.java new file mode 100644 index 0000000..bd627c8 --- /dev/null +++ b/src/ExercicesTP/IHM/IHMAjoutEtudiant.java @@ -0,0 +1,72 @@ +package ExercicesTP.IHM; +import javax.swing.*; +import java.awt.*; + +public class IHMAjoutEtudiant extends JInternalFrame{ + public JLabel nomLabel, prenomLabel, numEtdLabel, filiereLabel, niveauLabel, groupeLabel; + public JTextField nomField, prenomField, numEtdField; + public JComboBox filiereComboBox; + public JComboBox niveauComboBox, groupeComboBox; + + public JButton addButton, cancelButton; + public IHMAjoutEtudiant(){ + setTitle("Ajout d'un étudiant"); + setSize(400, 400); + initializeComponents(); + createLayout(); + //addEventListeners(); + setVisible(true); + } + private void addComponent(JPanel panel, JComponent component, GridBagConstraints c, int x, int y, int width, int height) { + c.gridx = x; + c.gridy = y; + c.gridwidth = width; + c.gridheight = height; + panel.add(component, c); + } + public void initializeComponents() { + nomLabel = new JLabel("Nom :"); + prenomLabel = new JLabel("Prénom :"); + numEtdLabel = new JLabel("Numéro étudiant :"); + filiereLabel = new JLabel("Filière :"); + niveauLabel = new JLabel("Niveau :"); + groupeLabel = new JLabel("Groupe :"); + + nomField = new JTextField(15); + prenomField = new JTextField(20); + numEtdField = new JTextField(15); + + // Sample data for comboboxes (replace with actual data source) + filiereComboBox = new JComboBox<>(new String[]{"FIA", "Licence Sc Info", "Licence Info de Gest", "Maths Info", "Physique Info", "Chimie Info", "Bio Info", "Eco Info", "Génie Info", "Info de Gestion", "Info de Comm"}); + niveauComboBox = new JComboBox<>(new Integer[]{1, 2, 3}); + groupeComboBox = new JComboBox<>(new Integer[]{1, 2, 3, 4, 5}); + + addButton = new JButton("Ajouter"); + cancelButton = new JButton("Annuler"); + + } + + public void createLayout() { + JPanel panel = new JPanel(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + + // Add labels and corresponding components + c.fill = GridBagConstraints.HORIZONTAL; + addComponent(panel, numEtdLabel, c, 0, 2, 1, 1); + addComponent(panel, numEtdField, c, 1, 2, 2, 1); + addComponent(panel, nomLabel, c, 0, 0, 1, 1); + addComponent(panel, nomField, c, 1, 0, 2, 1); + addComponent(panel, prenomLabel, c, 0, 1, 1, 1); + addComponent(panel, prenomField, c, 1, 1, 2, 1); + addComponent(panel, filiereLabel, c, 0, 3, 1, 1); + addComponent(panel, filiereComboBox, c, 1, 3, 2, 1); + addComponent(panel, niveauLabel, c, 0, 4, 1, 1); + addComponent(panel, niveauComboBox, c, 1, 4, 2, 1); + addComponent(panel, groupeLabel, c, 0, 5, 1, 1); + addComponent(panel, groupeComboBox, c, 1, 5, 2, 1); + addComponent(panel, addButton, c, 0, 6, 1, 1); + addComponent(panel, cancelButton, c, 1, 6, 1, 1); + add(panel); + } + +} \ No newline at end of file diff --git a/src/ExercicesTP/IHM/Principale.java b/src/ExercicesTP/IHM/Principale.java index b18f52c..fa6eb85 100644 --- a/src/ExercicesTP/IHM/Principale.java +++ b/src/ExercicesTP/IHM/Principale.java @@ -53,6 +53,7 @@ public class Principale extends JFrame { menuItemAjouteurEtudiant = new JMenuItem("Ajouteur"); menuItemRechercherEtudiant = new JMenuItem("Rechercher"); menuItemAfficherEtudiant = new JMenuItem("Afficher"); + menuEtudiant.add(menuItemAjouteurEtudiant); menuEtudiant.add(menuItemRechercherEtudiant); menuEtudiant.add(menuItemAfficherEtudiant); @@ -96,6 +97,14 @@ public void actionPerformed(ActionEvent e) { } }); + menuItemAjouteurEtudiant.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + IHMAjoutEtudiant ihmAjoutEtud = new IHMAjoutEtudiant(); + desktop.add(ihmAjoutEtud); + } + }); +