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