91 lines
2.7 KiB
Java
91 lines
2.7 KiB
Java
|
|
import javax.swing.*;
|
||
|
|
import java.awt.*;
|
||
|
|
import java.awt.event.*;
|
||
|
|
|
||
|
|
public class FenetreRappel extends JFrame implements ActionListener{
|
||
|
|
|
||
|
|
private final JButton btnFermer = new JButton("Fermer");
|
||
|
|
private final JButton btnModifier = new JButton("Modifier");
|
||
|
|
private final Main main;
|
||
|
|
private Rappel rappel;
|
||
|
|
|
||
|
|
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();
|
||
|
|
}
|
||
|
|
|
||
|
|
@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();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|