Files
SAE31_2025/src/fr/iutfbleau/papillon/FenetreRappel.java
T
2025-10-26 03:30:51 +01:00

127 lines
3.9 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package fr.iutfbleau.papillon;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
/**
* La classe <code>FenetreRappel</code> représente la fenêtre daffichage
* détaillée dun rappel dans lapplication <b>Papillon</b>.
* <p>
* Elle affiche les informations complètes du rappel sélectionné
* (titre, contenu, thème, et priorité) et permet à lutilisateur
* de le modifier ou de fermer la fenêtre.
* </p>
*
* @version 1.0
* @author Seri-khane YOLOU, Aylane SEHL, Jenson VAL
*/
public class FenetreRappel extends JFrame implements ActionListener{
/** Bouton permettant de fermer la fenêtre. */
private final JButton btnFermer = new JButton("Fermer");
/** Bouton permettant douvrir la fenêtre de modification du rappel. */
private final JButton btnModifier = new JButton("Modifier");
/** Référence vers la fenêtre principale de lapplication. */
private final Main main;
/** Référence vers le rappel à afficher. */
private Rappel rappel;
/**
* Constructeur de la fenêtre daffichage dun rappel.
*
* @param r le rappel à afficher
* @param main la fenêtre principale
*/
public FenetreRappel(Rappel r, Main main) {
super("Rappel : " + r.getTitre());
ImageIcon logo = new ImageIcon("logo.png");
setIconImage(logo.getImage());
this.main = main;
this.rappel = r;
setSize(350, 250);
setLocationRelativeTo(null);
setResizable(false);
setAlwaysOnTop(true);
setLocation(main.getLocation());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
JLabel titre = new JLabel("<html><h2>" + r.getTitre() + "</h2></html>");
JTextArea contenu = new JTextArea(r.getContenu());
contenu.setLineWrap(true);
contenu.setWrapStyleWord(true);
contenu.setEditable(false);
JLabel infos = new JLabel("<html><i>Thème : " + r.getTheme() + " <br>Rang : " + r.getRang() + "</i></html>");
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(4, 4, 4, 4);
c.fill = GridBagConstraints.HORIZONTAL;
panel.add(titre, c);
c.gridy = 1;
c.weightx = 1.0;
c.weighty = 1.0;
c.gridwidth = 2;
c.fill = GridBagConstraints.BOTH;
panel.add(new JScrollPane(contenu), c);
c.gridx = 0;
c.gridy = 2;
c.weightx = 0;
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
panel.add(infos, c);
btnModifier.addActionListener(this);
btnFermer.addActionListener(this);
JPanel btnPanel = new JPanel();
c.gridx = 1;
c.gridy = 2;
c.weightx = 0;
c.weighty = 0;
c.anchor = GridBagConstraints.EAST;
btnPanel.add(btnModifier);
btnPanel.add(btnFermer);
panel.add(btnPanel, c);
setContentPane(panel);
setVisible(true);
main.dispose();
}
/**
* Gère les actions effectuées sur les boutons de la fenêtre.
* <ul>
* <li><b>Fermer</b> : ferme la fenêtre actuelle.</li>
* <li><b>Modifier</b> : ouvre la fenêtre de modification du rappel.</li>
* </ul>
*
* @param e l’événement daction déclenché
*/
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnFermer) {
Main reParent = new Main();
reParent.setLocation(this.getLocation());
reParent.setVisible(true);
this.dispose();
}
else if (e.getSource() == btnModifier) {
FenetreModif f = new FenetreModif(main,rappel);
f.setVisible(true);
this.dispose();
}
}
}