From: Ricardo Markiewicz Date: Tue, 2 May 2006 19:56:56 +0000 (+0000) Subject: Draft de interfaz grafica. X-Git-Tag: darcs_import~5 X-Git-Url: https://git.llucax.com/z.facultad/75.62/c2tp1.git/commitdiff_plain/090b709ccc6c8cfeb88f15ff0f90e7a4bd09afc6?ds=sidebyside;hp=1783765ce04f5c11287a21a23956351f39fc95a7 Draft de interfaz grafica. --- 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); + } +}