// package fr.iutfbleau.papillon; import javax.swing.*; import java.awt.*; public class Main extends JFrame { public Main(){ super("Papillon"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // ----- Titre en haut ----- JLabel titre = new JLabel("Rappel : Papillon", SwingConstants.CENTER); titre.setBorder(BorderFactory.createEmptyBorder(6,10,6,10)); titre.setBackground(Color.CYAN); // ----- 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); } 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(); f.setVisible(true); } }