3 import java.awt.event.*;
6 public class FrGraf extends Frame implements Observer
11 private Fraccion fraccion;
13 public FrGraf (Fraccion f)
18 label = new Label(f.toString (), Label.CENTER);
19 boton = new Button ("Mitad!");
21 panel.setLayout (new BorderLayout ());
22 panel.add (label, BorderLayout.CENTER);
23 panel.add (boton, BorderLayout.SOUTH);
25 add (panel, BorderLayout.CENTER );
32 public boolean action (Event evt, Object obj) {
33 if (evt.target.equals(boton)) {
34 fraccion.setDen ( fraccion.getDen()*2);
40 public void update(Observable obs, Object obj)
42 if (obs instanceof Fraccion) {
43 label.setText (obs.toString ());
49 static public void main (String[] args) {
50 Fraccion modelo = null;
52 modelo = new Fraccion (5, 4);
57 FrGraf vista = new FrGraf (modelo);