From ea39de544e430a7487adc41eefb38499c39ed89a Mon Sep 17 00:00:00 2001 From: Jenson VAL Date: Mon, 20 Oct 2025 23:15:55 +0200 Subject: [PATCH] test mise en page --- src/fr/iutfbleau/papillon/Main.java | 88 +++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 22 deletions(-) diff --git a/src/fr/iutfbleau/papillon/Main.java b/src/fr/iutfbleau/papillon/Main.java index 77e43d8..92277b0 100644 --- a/src/fr/iutfbleau/papillon/Main.java +++ b/src/fr/iutfbleau/papillon/Main.java @@ -6,35 +6,79 @@ import java.awt.*; public class Main extends JFrame { public Main(){ - super("Papillon"); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setSize(400, 150); + super("Papillon"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - Crud crud = new Crud(); + // ----- Titre en haut ----- + JLabel titre = new JLabel("Rappel : Papillon", SwingConstants.CENTER); + titre.setBorder(BorderFactory.createEmptyBorder(6,10,6,10)); + titre.setBackground(Color.CYAN); + - JPanel panel = new JPanel(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); + // ----- Grille centrale : boutons a gauche + liste scrollable a droite ----- + JPanel body = new JPanel(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + + Crud crud = new Crud(this); + + // Colonne 0 : boutons + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.NORTHWEST; + c.insets = new Insets(5, 5, 5, 5); + c.gridx = 0; + c.gridy = 0; + body.add(crud.get(0), c); + + c.gridx = 0; + c.gridy = 1; + body.add(crud.get(1), c); + + // Colonne 1 : liste verticale de Rappel dans un JScrollPane + JPanel liste = new JPanel(); + liste.setLayout(new BoxLayout(liste, BoxLayout.Y_AXIS)); + + //rappels + + for (int i = 0; i < 5; i++) { + Rappel r = new Rappel(); + liste.add(r); - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.WEST; - c.weightx = 1.0; - c.insets = new Insets(4, 4, 4, 4); - - - - c.gridx = 0; - c.gridy = 0; - panel.add(crud.get(0), c); - - c.gridx = 0; - c.gridy = 1; - panel.add(crud.get(1), c); - - setContentPane(panel); } + JScrollPane scroll = new JScrollPane( + liste, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER + ); + scroll.getVerticalScrollBar().setUnitIncrement(16); // molette fluide + // place le scrollpane a droite, sur la hauteur des 2 lignes + c.gridx = 1; + c.gridy = 0; + c.gridheight = 2; + 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); + + // Conteneur racine + JPanel root = new JPanel(new BorderLayout()); + root.add(titre, BorderLayout.NORTH); + root.add(body, BorderLayout.CENTER); + setContentPane(root); + + // Taille fixe + setSize(350, 250); + setResizable(false); + + } + +public void setFenetre(){ +FenetreAjout update = new FenetreAjout(); +update.setVisible(true); +} public static void main(String[] args) { Main f = new Main();