diff --git a/src/fr/iutfbleau/papillon/Main.java b/src/fr/iutfbleau/papillon/Main.java index 9407483..bd3b66a 100644 --- a/src/fr/iutfbleau/papillon/Main.java +++ b/src/fr/iutfbleau/papillon/Main.java @@ -2,8 +2,12 @@ import javax.swing.*; import java.awt.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Arrays; public class Main extends JFrame { + private final List listRpl = new ArrayList<>(); public Main(){ super("Papillon"); @@ -25,25 +29,31 @@ public class Main extends JFrame { // Colonne 0 : boutons c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; - c.insets = new Insets(5, 5, 5, 5); + c.insets = new Insets(4, 4, 4, 4); + for(int i = 0; i< crud.size() ;i++){ c.gridx = 0; - c.gridy = 0; - body.add(crud.get(0), c); - - c.gridx = 0; - c.gridy = 1; - body.add(crud.get(1), c); + c.gridy = i; + c.weighty = 0; + body.add(crud.get(i), c); + } // Colonne 1 : liste verticale de Rappel dans un JScrollPane JPanel liste = new JPanel(); liste.setLayout(new BoxLayout(liste, BoxLayout.Y_AXIS)); - //rappels + //Rappels + GestionRappel g = new GestionRappel(); + List listBd = new ArrayList<>(); +try { + listBd = g.lister(); +} catch (Exception e) { + e.printStackTrace(); // affiche l'erreur dans le terminal +} - for (int i = 0; i < 5; i++) { - Rappel r = new Rappel(); - liste.add(r); - + for (int i = 0; i < listBd.size() ; i++) { + PanelRappel r = new PanelRappel(listBd.get(i)); + liste.add(r); + listRpl.add(r); } JScrollPane scroll = new JScrollPane( @@ -56,17 +66,25 @@ public class Main extends JFrame { // place le scrollpane a droite, sur la hauteur des 2 lignes c.gridx = 1; c.gridy = 0; - c.gridheight = 2; + c.gridheight = 3; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(0, 0, 0, 0); c.weightx = 1.0; // prend la largeur dispo c.weighty = 1.0; // prend la hauteur dispo body.add(scroll, c); + // barre en bas + JLabel txtbarre = new JLabel("-", SwingConstants.CENTER); + JPanel barre = new JPanel(); + barre.add(txtbarre); + barre.setBorder(BorderFactory.createEmptyBorder(1,1,1,1)); + // barre.setBackground(Color.GRAY); + // Conteneur racine JPanel root = new JPanel(new BorderLayout()); root.add(titre, BorderLayout.NORTH); root.add(body, BorderLayout.CENTER); + root.add(barre, BorderLayout.SOUTH); setContentPane(root); // Taille fixe @@ -76,23 +94,8 @@ public class Main extends JFrame { } - -public void ouvrirFenetreAjout() { - FenetreAjout f = new FenetreAjout(this); - // cacher la fenetre actuelle et montrer celle d ajout - - // récupère la position actuelle de Main - Point pos = this.getLocation(); - f.setLocation(pos); // place FenetreAjout au même endroit - - f.setVisible(true); - this.setVisible(false); - +public List getPanelRpl(){ + return listRpl; } - public static void main(String[] args) { - - Main f = new Main(); - f.setVisible(true); - } } \ No newline at end of file