DEV/BUT1/DEV2.1/TP3-MiseEnPage/EXO3/exo3.java

40 lines
1.2 KiB
Java
Raw Permalink Normal View History

2024-02-02 23:10:00 +01:00
import javax.swing.*;
import java.awt.*;
public class exo3 {
2024-02-05 10:23:12 +01:00
public static void main(String[] args) {
2024-02-09 20:01:31 +01:00
// Création de la fenêtre + configuration
2024-02-05 10:23:12 +01:00
JFrame fenetre = new JFrame("Exo3");
fenetre.setSize(200, 200);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
2024-02-09 20:01:31 +01:00
// Création du grid layout + ajout à la fenêtre
GridLayout grid = new GridLayout(2,1);
fenetre.setLayout(grid);
// Création d'un panneau avec la question + configuration du panneau
JLabel texte = new JLabel("Aimez-vous les chiens ?");
texte.setPreferredSize(new Dimension(486, 20));
texte.setHorizontalAlignment(JLabel.CENTER);
// Création d'un FlowLayout + ajout à la fenêtre
FlowLayout gestionnaire = new FlowLayout(FlowLayout.CENTER);
// Création des boutons + ajouts à la fenêtre
2024-02-05 10:23:12 +01:00
JButton yes = new JButton("Oui");
JButton no = new JButton("Non");
JButton maybe = new JButton("NSPP");
2024-02-09 20:01:31 +01:00
JPanel panneau = new JPanel();
panneau.add(yes);
panneau.add(no);
panneau.add(maybe);
fenetre.add(texte);
fenetre.add(panneau);
// On rend la fenêtre visible
2024-02-05 10:23:12 +01:00
fenetre.setVisible(true);
}
}