]> git.llucax.com Git - z.facultad/75.62/c2tp1.git/commitdiff
Draft de interfaz grafica.
authorRicardo Markiewicz <rmarkie@fi.uba.ar>
Tue, 2 May 2006 19:56:56 +0000 (19:56 +0000)
committerRicardo Markiewicz <rmarkie@fi.uba.ar>
Tue, 2 May 2006 19:56:56 +0000 (19:56 +0000)
src/FrGraf.java [new file with mode: 0644]

diff --git a/src/FrGraf.java b/src/FrGraf.java
new file mode 100644 (file)
index 0000000..b81eb65
--- /dev/null
@@ -0,0 +1,45 @@
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+
+public class FrGraf extends Frame implements Observer
+{
+       private Panel panel;
+       private Label label;
+
+       public FrGraf (Fraccion f)
+       {
+               panel = new Panel ();
+               label = new Label(f.toString (), Label.CENTER);
+
+               panel.setLayout (new BorderLayout ());
+               panel.add (label, BorderLayout.CENTER);
+       
+               add (panel, BorderLayout.CENTER );
+               setSize (500, 300);
+               setVisible (true);
+                       
+               f.addObserver (this);
+       }
+
+       public void update(Observable obs, Object obj)
+       {
+               if (obj instanceof Fraccion) {
+                       label.setText (obj.toString ());
+               } else {
+                       label.setText ("E");
+               }
+       }
+
+       static public void main (String[] args) {
+               Fraccion modelo = null;
+               try {
+                       modelo = new Fraccion (5, 4);
+               }
+               catch (Exception e) {
+               }
+
+               FrGraf vista = new FrGraf (modelo);
+       }
+}