Files
SAE31_2025/src/fr/iutfbleau/papillon/Main.java
T

87 lines
2.2 KiB
Java
Raw Normal View History

2025-10-19 02:30:54 +02:00
// package fr.iutfbleau.papillon;
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main(){
2025-10-20 23:15:55 +02:00
super("Papillon");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
2025-10-19 02:30:54 +02:00
2025-10-20 23:15:55 +02:00
// ----- Titre en haut -----
JLabel titre = new JLabel("Rappel : Papillon", SwingConstants.CENTER);
titre.setBorder(BorderFactory.createEmptyBorder(6,10,6,10));
titre.setBackground(Color.CYAN);
2025-10-19 02:30:54 +02:00
2025-10-20 23:15:55 +02:00
// ----- 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);
2025-10-19 02:30:54 +02:00
}
2025-10-20 23:15:55 +02:00
JScrollPane scroll = new JScrollPane(
liste,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER
);
scroll.getVerticalScrollBar().setUnitIncrement(16); // molette fluide
2025-10-19 02:30:54 +02:00
2025-10-20 23:15:55 +02:00
// 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);
}
2025-10-19 02:30:54 +02:00
public static void main(String[] args) {
Main f = new Main();
f.setVisible(true);
}
}