40 lines
1.3 KiB
Java
40 lines
1.3 KiB
Java
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.util.Deque;
|
|
import java.util.ArrayDeque;
|
|
|
|
public class Fenetre extends JFrame{
|
|
|
|
private Deque<JCheckBox> historique;
|
|
|
|
public Fenetre(){
|
|
super();
|
|
this.setTitle("Question1");
|
|
this.setSize(500, 300);
|
|
this.setLocation(0, 0);
|
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
this.historique = new ArrayDeque<>();
|
|
this.addIngredient();
|
|
}
|
|
|
|
private void addIngredient(){
|
|
JButton retour = new JButton("RETOUR");
|
|
EvenementIngredient evenementIngredient = new EvenementIngredient(this.historique, retour);
|
|
Ingredient[] listeIngredient = Ingredient.values();
|
|
int nbIngredient = listeIngredient.length;
|
|
JCheckBox[] listeCoche = new JCheckBox[nbIngredient];
|
|
int i;
|
|
this.setLayout(new GridLayout(nbIngredient+1,1));
|
|
|
|
for (i=0; i<nbIngredient; i++){
|
|
listeCoche[i] = new JCheckBox(listeIngredient[i].name());
|
|
listeCoche[i].addItemListener(evenementIngredient);
|
|
this.add(listeCoche[i]);
|
|
}
|
|
|
|
EvenementRetour evenementRetour = new EvenementRetour(this.historique);
|
|
retour.setEnabled(false);
|
|
retour.addActionListener(evenementRetour);
|
|
this.add(retour);
|
|
}
|
|
} |