DEV/BUT1/DEV2.1/TP3-MiseEnPage/EXO1/exo1.java

43 lines
1.4 KiB
Java
Raw Permalink Normal View History

2024-02-01 23:19:01 +01:00
import javax.swing.*;
import java.awt.*;
public class exo1 {
public static void main(String[] args) {
// un objet pour servir de fenetre
JFrame fenetre = new JFrame();
2024-02-02 20:34:17 +01:00
Dimension tailleMin = new Dimension(500,400);
Dimension tailleMax = new Dimension(1200,400);
Dimension taillePref = new Dimension(500, 400);
2024-02-01 23:19:01 +01:00
// on configure la fenetre
2024-02-02 20:34:17 +01:00
fenetre.setSize(700, 400);
fenetre.setMinimumSize(tailleMin);
fenetre.setMaximumSize(tailleMax);
2024-02-01 23:19:01 +01:00
fenetre.setLocation(100, 100);
2024-02-02 20:34:17 +01:00
fenetre.setPreferredSize(taillePref);
2024-02-01 23:19:01 +01:00
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// On crée une zone de texte
JRadioButton boutonRadio1 = new JRadioButton("Gryffondor");
JRadioButton boutonRadio2 = new JRadioButton("Serdaigle");
JRadioButton boutonRadio3 = new JRadioButton("Serpentard");
JRadioButton boutonRadio4 = new JRadioButton("Poufsouffle");
ButtonGroup Groupe = new ButtonGroup();
Groupe.add(boutonRadio1);
Groupe.add(boutonRadio2);
Groupe.add(boutonRadio3);
Groupe.add(boutonRadio4);
// on ajoute le composant dans la fenetre, au milieu
2024-02-02 23:10:00 +01:00
GridLayout gestionnaire = new GridLayout(4,4);
2024-02-02 20:34:17 +01:00
fenetre.setLayout(gestionnaire);
fenetre.add(boutonRadio1);
fenetre.add(boutonRadio2);
fenetre.add(boutonRadio3);
fenetre.add(boutonRadio4);
2024-02-01 23:19:01 +01:00
// et on montre le resultat
fenetre.setVisible(true);
}
2024-02-05 10:23:12 +01:00
}