38 lines
1.2 KiB
Java
38 lines
1.2 KiB
Java
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
|
||
|
public class Fenetre extends JFrame{
|
||
|
|
||
|
private PileIngredient historique;
|
||
|
|
||
|
public Fenetre(){
|
||
|
super();
|
||
|
this.setTitle("Question1");
|
||
|
this.setSize(500, 300);
|
||
|
this.setLocation(0, 0);
|
||
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||
|
this.historique = new PileIngredient();
|
||
|
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;
|
||
|
Coche[] listeCoche = new Coche[nbIngredient];
|
||
|
int i;
|
||
|
this.setLayout(new GridLayout(1,nbIngredient+1));
|
||
|
|
||
|
for (i=0; i<nbIngredient; i++){
|
||
|
listeCoche[i] = new Coche(listeIngredient[i]);
|
||
|
listeCoche[i].addItemListener(evenementIngredient);
|
||
|
this.add(listeCoche[i]);
|
||
|
}
|
||
|
|
||
|
EvenementRetour evenementRetour = new EvenementRetour(this.historique, listeCoche, evenementIngredient);
|
||
|
retour.setEnabled(false);
|
||
|
retour.addActionListener(evenementRetour);
|
||
|
this.add(retour);
|
||
|
}
|
||
|
}
|