2025-10-26 02:14:25 +01:00
|
|
|
|
package fr.iutfbleau.papillon;
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.event.*;
|
2025-10-25 19:37:15 +02:00
|
|
|
|
import javax.swing.*;
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
|
|
2025-10-26 02:14:25 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* La classe <code>FenetreRappel</code> représente la fenêtre d’affichage
|
|
|
|
|
|
* détaillée d’un rappel dans l’application <b>Papillon</b>.
|
|
|
|
|
|
* <p>
|
|
|
|
|
|
* Elle affiche les informations complètes du rappel sélectionné
|
|
|
|
|
|
* (titre, contenu, thème, et priorité) et permet à l’utilisateur
|
|
|
|
|
|
* de le modifier ou de fermer la fenêtre.
|
|
|
|
|
|
* </p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
* @author Seri-khane YOLOU, Aylane SEHL, Jenson VAL
|
|
|
|
|
|
*/
|
2025-10-25 19:37:15 +02:00
|
|
|
|
public class FenetreRappel extends JFrame implements ActionListener{
|
|
|
|
|
|
|
2025-10-26 02:14:25 +01:00
|
|
|
|
/** Bouton permettant de fermer la fenêtre. */
|
2025-10-25 19:37:15 +02:00
|
|
|
|
private final JButton btnFermer = new JButton("Fermer");
|
2025-10-26 02:14:25 +01:00
|
|
|
|
|
|
|
|
|
|
/** Bouton permettant d’ouvrir la fenêtre de modification du rappel. */
|
2025-10-25 19:37:15 +02:00
|
|
|
|
private final JButton btnModifier = new JButton("Modifier");
|
2025-10-26 02:14:25 +01:00
|
|
|
|
|
|
|
|
|
|
/** Référence vers la fenêtre principale de l’application. */
|
2025-10-25 19:37:15 +02:00
|
|
|
|
private final Main main;
|
2025-10-26 02:14:25 +01:00
|
|
|
|
|
|
|
|
|
|
/** Référence vers le rappel à afficher. */
|
2025-10-25 19:37:15 +02:00
|
|
|
|
private Rappel rappel;
|
|
|
|
|
|
|
2025-10-26 02:14:25 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* Constructeur de la fenêtre d’affichage d’un rappel.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param r le rappel à afficher
|
|
|
|
|
|
* @param main la fenêtre principale
|
|
|
|
|
|
*/
|
2025-10-25 19:37:15 +02:00
|
|
|
|
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();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-26 02:14:25 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* 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 d’action déclenché
|
|
|
|
|
|
*/
|
2025-10-25 19:37:15 +02:00
|
|
|
|
@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();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|