2025-10-23 09:00:30 +02:00
|
|
|
import javax.swing.*;
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
|
2025-10-25 20:10:19 +02:00
|
|
|
public class FenetreModif extends JFrame {
|
2025-10-23 09:00:30 +02:00
|
|
|
|
2025-10-25 20:10:19 +02:00
|
|
|
|
|
|
|
|
private GestionModif listBtnModif;
|
2025-10-23 09:00:30 +02:00
|
|
|
|
|
|
|
|
private final JTextField champTitre;
|
|
|
|
|
private final JTextArea champContenu;
|
|
|
|
|
private Integer[] nombres = {1, 2, 3, 4, 5};
|
|
|
|
|
private JComboBox<Integer> rang = new JComboBox<>(nombres);
|
2025-10-25 20:10:19 +02:00
|
|
|
|
|
|
|
|
private final String[] nomsCouleurs = {"Bleu", "Rouge", "Vert", "Jaune", "Rose"};
|
2025-10-23 09:00:30 +02:00
|
|
|
private final JComboBox<String> comboTheme = new JComboBox<>(nomsCouleurs);
|
|
|
|
|
|
2025-10-25 20:10:19 +02:00
|
|
|
public FenetreModif(Main parent, Rappel rappel) {
|
2025-10-23 09:00:30 +02:00
|
|
|
super("Modifier un rappel");
|
2025-10-25 20:10:19 +02:00
|
|
|
ImageIcon logo = new ImageIcon("logo.png");
|
|
|
|
|
setIconImage(logo.getImage());
|
2025-10-23 09:00:30 +02:00
|
|
|
|
|
|
|
|
setSize(350, 250);
|
|
|
|
|
setResizable(false);
|
2025-10-25 20:10:19 +02:00
|
|
|
setAlwaysOnTop(true);
|
2025-10-23 09:00:30 +02:00
|
|
|
setLocation(parent.getLocation()); // même position que Main
|
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
|
|
2025-10-25 20:10:19 +02:00
|
|
|
// UI
|
2025-10-23 09:00:30 +02:00
|
|
|
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;
|
2025-10-25 20:10:19 +02:00
|
|
|
add(centre, BorderLayout.CENTER);
|
2025-10-23 09:00:30 +02:00
|
|
|
// Titre
|
|
|
|
|
JLabel lblTitre = new JLabel("Titre :");
|
|
|
|
|
champTitre = new JTextField(20);
|
2025-10-25 20:10:19 +02:00
|
|
|
champTitre.setDocument(new LimiteContenu(50));
|
|
|
|
|
c.gridx = 0;
|
|
|
|
|
c.gridy = 1;
|
|
|
|
|
c.weightx = 0;
|
2025-10-23 09:00:30 +02:00
|
|
|
centre.add(lblTitre, c);
|
2025-10-25 20:10:19 +02:00
|
|
|
c.gridx = 1;
|
|
|
|
|
c.gridy = 1;
|
|
|
|
|
c.weightx = 1;
|
2025-10-23 09:00:30 +02:00
|
|
|
centre.add(champTitre, c);
|
|
|
|
|
|
|
|
|
|
// Contenu
|
|
|
|
|
JLabel lblContenu = new JLabel("Contenu :");
|
|
|
|
|
champContenu = new JTextArea(4, 20);
|
2025-10-25 20:10:19 +02:00
|
|
|
champContenu.setDocument(new LimiteContenu(200));
|
2025-10-23 09:00:30 +02:00
|
|
|
champContenu.setLineWrap(true); // active le retour à la ligne
|
|
|
|
|
champContenu.setWrapStyleWord(true); // évite de couper un mot en plein milieu
|
2025-10-25 20:10:19 +02:00
|
|
|
JScrollPane scroll = new JScrollPane(champContenu,
|
|
|
|
|
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
|
|
|
|
|
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
2025-10-23 09:00:30 +02:00
|
|
|
|
2025-10-25 20:10:19 +02:00
|
|
|
c.gridx = 0;
|
|
|
|
|
c.gridy = 2;
|
|
|
|
|
c.weightx = 0;
|
2025-10-23 09:00:30 +02:00
|
|
|
c.fill = GridBagConstraints.BOTH;
|
2025-10-25 20:10:19 +02:00
|
|
|
centre.add(lblContenu, c);
|
|
|
|
|
c.gridx = 1;
|
|
|
|
|
c.gridy = 2;
|
|
|
|
|
c.weightx = 1.0;
|
|
|
|
|
c.weighty = 1.0;
|
2025-10-23 09:00:30 +02:00
|
|
|
centre.add(scroll, c);
|
|
|
|
|
|
|
|
|
|
// rang
|
2025-10-25 20:10:19 +02:00
|
|
|
|
2025-10-23 09:00:30 +02:00
|
|
|
rang.setSelectedIndex(rappel.getRang()-1);
|
|
|
|
|
JLabel lblRang = new JLabel("Rang :");
|
2025-10-25 20:10:19 +02:00
|
|
|
c.gridx = 0;
|
|
|
|
|
c.gridy = 3;
|
|
|
|
|
c.weightx = 0;
|
|
|
|
|
c.weighty = 0.0;
|
2025-10-23 09:00:30 +02:00
|
|
|
centre.add(lblRang, c);
|
2025-10-25 20:10:19 +02:00
|
|
|
c.gridx = 1;
|
|
|
|
|
c.gridy = 3;
|
|
|
|
|
c.weightx = 1;
|
2025-10-23 09:00:30 +02:00
|
|
|
centre.add(rang, c);
|
|
|
|
|
|
|
|
|
|
// theme
|
2025-10-25 20:10:19 +02:00
|
|
|
c.gridx = 0;
|
|
|
|
|
c.gridy = 4;
|
|
|
|
|
c.weightx = 0;
|
2025-10-23 09:00:30 +02:00
|
|
|
centre.add(new JLabel("Theme :"), c);
|
|
|
|
|
|
|
|
|
|
// liste déroulante de couleurs
|
2025-10-25 20:10:19 +02:00
|
|
|
c.gridx = 1;
|
|
|
|
|
c.gridy = 4;
|
|
|
|
|
c.weightx = 1;
|
2025-10-23 09:00:30 +02:00
|
|
|
comboTheme.setRenderer(new CouleurList());
|
|
|
|
|
comboTheme.setSelectedItem(rappel.getTheme()); // valeur par défaut
|
|
|
|
|
centre.add(comboTheme, c);
|
|
|
|
|
|
2025-10-25 20:10:19 +02:00
|
|
|
// add(centre, BorderLayout.CENTER);
|
2025-10-23 09:00:30 +02:00
|
|
|
|
|
|
|
|
// Bas : boutons
|
|
|
|
|
JPanel bas = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
2025-10-25 20:10:19 +02:00
|
|
|
|
|
|
|
|
listBtnModif = new GestionModif(this,parent,champTitre,champContenu,rang,comboTheme,rappel);
|
|
|
|
|
bas.add(listBtnModif.get(0));
|
|
|
|
|
bas.add(listBtnModif.get(1));
|
2025-10-23 09:00:30 +02:00
|
|
|
add(bas, BorderLayout.SOUTH);
|
|
|
|
|
|
|
|
|
|
champTitre.setText(rappel.getTitre());
|
|
|
|
|
champContenu.setText(rappel.getContenu());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|