1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
   | public class VueResultat extends JPanel implements Vue {
    private Mastermind jeux;
    JLabel [] tab;
    protected int tabaffiche [];
    int j=1;
 
 
       public VueResultat (Mastermind jeux) {
 
         super();
         this.jeux=jeux;
         this.tabaffiche = new int[4];
         this.tab = new JLabel[4];
         this.setLayout(new GridLayout(1,4));
 
 
          for(int i=0;i<4;i++){
         tab[i]=new JLabel (new ImageIcon("./image/test.jpg"));
         this.add(tab[i]);}
 
public void mettreAJour() {
     for(int i=0;i<4;i++){
            tabaffiche[i] = jeux.majTabaffichage(i);
     }
 
      j++;
 
     this.setLayout(new GridLayout(j,4));
 
              this.tab=new JLabel [4];
       for(int i=0;i<4;i++){
          int t = this.tabaffiche [i] ;
          if ( t==0){
             this.tab[i]= new JLabel (new ImageIcon("./image/bleu.jpg"));}
          else if (t==1){
            this.tab[i]= new JLabel (new ImageIcon("./image/rouge.jpg"));}
          else if (t==2){
             this.tab[i]= new JLabel (new ImageIcon("./image/vert.jpg"));}
          else if (t==3){
             this.tab[i]= new JLabel (new ImageIcon("./image/noire.jpg"));}
           }
 
 
         for(int i=0;i<4;i++){
           this.add(this.tab[i]);}
     } | 
Partager