
import javax.swing.JLabel;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Andréa
 */
public class AffichageValeurs extends JLabel implements Observer {
    
    String a;
    String b;
    String c;

    public AffichageValeurs(Triplet t) {
            super("",JLabel.CENTER);

            t.addObserver(this);

            a = String.valueOf(t.getA());
            b = String.valueOf(t.getB());
            c = String.valueOf(t.getC());

            afficher();
    }

    public void afficher() {
            setText(
                    "A = " + a + " : " +
                    "B = " + b + " : " +
                    "C = " + c
                    );
    }

    public void update(Triplet.FieldName fieldName, Integer newValue) {
        switch(fieldName){
            case A:
                a = String.valueOf(newValue);
                break;
            case B:
                b = String.valueOf(newValue);
                break;
            case C:
                c = String.valueOf(newValue);
                break;
        }
        afficher();
        repaint();
    }
}
