3 import java.awt.event.*;
6 public class AngGraf extends Frame implements Observer
11 private AngCanvas canvas;
12 private Angulo angulo;
14 public AngGraf (Angulo f)
19 label = new Label(f.toString (), Label.CENTER);
20 boton = new Button ("Mitad!");
21 canvas = new AngCanvas (f);
23 panel.setLayout (new BorderLayout ());
24 panel.add (label, BorderLayout.NORTH);
25 panel.add (canvas, BorderLayout.CENTER);
26 panel.add (boton, BorderLayout.SOUTH);
28 add (panel, BorderLayout.CENTER );
33 f.addObserver (canvas);
36 public boolean action (Event evt, Object obj) {
37 if (evt.target.equals(boton)) {
38 angulo.fromRadianes ( angulo.toRadianes () / 2);
44 public void update(Observable obs, Object obj)
46 label.setText (obs.toString ());
49 static public void main (String[] args) {
52 modelo = new Angulo (359, 0, 0);
57 AngGraf vista = new AngGraf (modelo);