+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+
+public class FrameCantores extends Panel implements Observer
+{
+ private Label nombre;
+ private Label valor;
+
+ public FrameCantores (Cantadores c)
+ {
+ nombre = new Label (c.getNombre ());
+ valor = new Label ("No canto nada");
+
+ setLayout (new BorderLayout ());
+ add (nombre, BorderLayout.CENTER);
+ add (valor, BorderLayout.SOUTH);
+
+ setSize (50, 100);
+ setVisible (true);
+
+ c.addObserver (this);
+ }
+
+ public void update(Observable obs, Object obj)
+ {
+ if (obs instanceof Cantadores) {
+ valor.setText ((new Integer (((Cantadores)obs).getLastN ())).toString ());
+ }
+ }
+
+ static public void main (String [] args)
+ {
+ Sorteo s = new Sorteo ();
+ Cantadores c1 = new Cantadores ("Pablo");
+ Cantadores c2 = new Cantadores ("Mariela");
+ Cantadores c3 = new Cantadores ("Angela");
+ s.addObserver (c1);
+ s.addObserver (c2);
+ s.addObserver (c3);
+
+ FrameCantores f1 = new FrameCantores (c1);
+ FrameCantores f2 = new FrameCantores (c2);
+ FrameCantores f3 = new FrameCantores (c3);
+
+ Frame p = new Frame ();
+ p.setLayout (new BorderLayout ());
+ p.add (f1, BorderLayout.WEST);
+ p.add (f2, BorderLayout.CENTER);
+ p.add (f3, BorderLayout.EAST);
+
+ p.setSize (500, 100);
+ p.setVisible (true);
+ s.Go ();
+ }
+}
+