DEV_BUT1/DEV2.1/TP03/Choix.java

40 lines
1.3 KiB
Java
Raw Normal View History

2023-02-08 11:18:16 +01:00
import javax.swing.*;
import java.awt.*;
2023-04-04 14:03:16 +02:00
public class Choix{
2023-02-08 11:18:16 +01:00
public static void main(String[] args) {
// un objet pour servir de fenetre
JFrame fenetre = new JFrame();
// on configure la fenetre
fenetre.setSize(500, 300);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JRadioButton Gryffondor = new JRadioButton("Gryffondor");
Gryffondor.setHorizontalAlignment(JRadioButton.CENTER);
fenetre.add(Gryffondor, BorderLayout.NORTH);
JRadioButton Serdaigle = new JRadioButton("Serdaigle");
Serdaigle.setHorizontalAlignment(JRadioButton.CENTER);
2023-04-04 14:03:16 +02:00
fenetre.add(Serdaigle, BorderLayout.EAST);
2023-02-08 11:18:16 +01:00
JRadioButton Serpentard = new JRadioButton("Serpentard");
Serpentard.setHorizontalAlignment(JRadioButton.CENTER);
2023-04-04 14:03:16 +02:00
fenetre.add(Serpentard, BorderLayout.WEST);
JRadioButton Poufsouffle = new JRadioButton("PoufsouffleEclaté");
Poufsouffle.setHorizontalAlignment(JRadioButton.CENTER);
fenetre.add(Poufsouffle, BorderLayout.SOUTH);
2023-02-08 11:18:16 +01:00
ButtonGroup Groupe = new ButtonGroup();
Groupe.add(Gryffondor);
Groupe.add(Serdaigle);
Groupe.add(Serpentard);
2023-04-04 14:03:16 +02:00
Groupe.add(Poufsouffle);
2023-02-08 11:18:16 +01:00
2023-04-04 14:03:16 +02:00
Dimension size = new Dimension(300,150);
fenetre.setMinimumSize(size);
2023-02-08 11:18:16 +01:00
fenetre.setVisible(true);
}
}