From ef2ee630efd31c9a798646588ae6deadf3ca7734 Mon Sep 17 00:00:00 2001 From: Aylane SEHL Date: Mon, 20 Oct 2025 23:20:52 +0200 Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20vers=20?= =?UTF-8?q?"src/fr/iutfbleau/papillon"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajoute de la fenetre principale --- src/fr/iutfbleau/papillon/FenetreAjout.java | 99 +++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/fr/iutfbleau/papillon/FenetreAjout.java diff --git a/src/fr/iutfbleau/papillon/FenetreAjout.java b/src/fr/iutfbleau/papillon/FenetreAjout.java new file mode 100644 index 0000000..9a2d67e --- /dev/null +++ b/src/fr/iutfbleau/papillon/FenetreAjout.java @@ -0,0 +1,99 @@ +// package fr.iutfbleau.papillon; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class FenetreAjout extends JFrame implements ActionListener { + + private final JTextField champTitre; + private final JTextArea champContenu; + private final JButton boutonValider; + private final JButton boutonAnnuler; + + public FenetreAjout() { + super("Ajouter un rappel"); + + setSize(300, 200); + setResizable(false); + setLocationRelativeTo(null); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + // Layout principal + setLayout(new BorderLayout(10, 10)); + JPanel centre = new JPanel(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + c.insets = new Insets(4, 4, 4, 4); + c.fill = GridBagConstraints.HORIZONTAL; + add(centre, BorderLayout.CENTER); + + // Titre + JLabel lblTitre = new JLabel("Titre :"); + champTitre = new JTextField(20); + c.gridx = 0; + c.gridy = 0; + c.weightx = 0; + centre.add(lblTitre, c); + c.gridx = 1; + c.gridy = 0; + c.weightx = 1; + centre.add(champTitre, c); + + // Contenu + JLabel lblContenu = new JLabel("Contenu :"); + champContenu = new JTextArea(4, 20); + JScrollPane scroll = new JScrollPane(champContenu, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + + c.gridx = 0; + c.gridy = 1; + c.weightx = 0; + c.fill = GridBagConstraints.BOTH; + centre.add(lblContenu, c); + c.gridx = 1; + c.gridy = 1; + c.weightx = 1; + centre.add(scroll, c); + + // Bas : boutons + JPanel bas = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10)); + boutonValider = new JButton("Valider"); + boutonAnnuler = new JButton("Annuler"); + + // on enregistre les actions ici + boutonValider.addActionListener(this); + boutonAnnuler.addActionListener(this); + + bas.add(boutonValider); + bas.add(boutonAnnuler); + add(bas, BorderLayout.SOUTH); + } + + @Override + public void actionPerformed(ActionEvent e) { + Object source = e.getSource(); + + if (source == boutonAnnuler) { + dispose(); // ferme la fenêtre + } + else if (source == boutonValider) { + String titre = champTitre.getText().trim(); + String contenu = champContenu.getText().trim(); + + if (titre.isEmpty() || contenu.isEmpty()) { + JOptionPane.showMessageDialog(this, + "Veuillez remplir les deux champs.", + "Champs manquants", + JOptionPane.WARNING_MESSAGE); + return; + } + + // pour l’instant, juste un message (tu pourras relier à Main plus tard) + JOptionPane.showMessageDialog(this, + "Rappel ajouté :\nTitre : " + titre + "\nContenu : " + contenu); + + dispose(); + } + } +}