From 090b709ccc6c8cfeb88f15ff0f90e7a4bd09afc6 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 2 May 2006 19:56:56 +0000 Subject: [PATCH] Draft de interfaz grafica. --- src/FrGraf.java | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/FrGraf.java diff --git a/src/FrGraf.java b/src/FrGraf.java new file mode 100644 index 0000000..b81eb65 --- /dev/null +++ b/src/FrGraf.java @@ -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); + } +} -- 2.43.0