home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / afc102 / JTreeVue / Src / JTreeVue.java < prev    next >
Encoding:
Java Source  |  2000-05-04  |  1.8 KB  |  82 lines

  1. //
  2. // (C) Copyright 1995 - 1999 Microsoft Corporation.  All rights reserved.
  3. //
  4. import java.awt.Event;
  5. import java.awt.image.*;
  6. import java.io.*;
  7. import java.net.URL;
  8. import java.net.MalformedURLException;
  9. import java.util.Vector;
  10. import java.util.Enumeration;
  11. import java.util.Hashtable;
  12.  
  13. import com.ms.ui.*;
  14. import com.ms.fx.*;
  15.  
  16. // Awt wrapper for UIApplet
  17. public class JTreeVue extends AwtUIApplet
  18. {
  19.     public JTreeVue() { super(new JTVApplet()); }
  20.  
  21.     // Application CODE
  22.     public static void main(String args[])
  23.     {
  24.         try { new JTVFrame(); } catch (Exception e) { e.printStackTrace(); }
  25.     }
  26. }
  27.  
  28. // Applet CODE
  29. class JTVApplet extends UIApplet
  30. {
  31.     private JTreeVuePanel jtree;
  32.  
  33.     public void init()
  34.     {
  35.         try {
  36.         setLayout(new UIBorderLayout(0, 0));
  37.         setFont(new FxFont("Dialog", FxFont.BOLD, 12));
  38.         URL url = new URL(getCodeBase(), "tree.html");
  39.         InputStream stream = url.openStream();
  40.         jtree = new JTreeVuePanel(stream);
  41.         add(jtree, "Center");
  42.         } catch (Exception e) { e.printStackTrace(); }
  43.     }
  44.  
  45.     public void start()
  46.     {
  47.         jtree.objroot.getHeader().requestFocus();
  48.     }
  49. }
  50.  
  51. // Application CODE
  52. class JTVFrame extends UIFrame
  53. {
  54.     private JTreeVuePanel jtree;
  55.  
  56.     public JTVFrame()
  57.     {
  58.         super("Java Class Hierarchy Application");
  59.         setBackground(java.awt.Color.lightGray);
  60.         setLayout(new UIBorderLayout(0, 0));
  61.         setFont(new FxFont("Dialog", FxFont.BOLD, 12));
  62.  
  63.         try {
  64.             FileInputStream stream = new FileInputStream("tree.html");
  65.             jtree = new JTreeVuePanel(stream);
  66.             add(jtree, "Center");
  67.             setSize(350, 400);
  68.             setVisible(true);
  69.             jtree.objroot.getHeader().requestFocus();
  70.         } catch ( Exception e ) { e.printStackTrace(); }
  71.     }
  72.  
  73.     public boolean handleEvent(Event evt)
  74.     {
  75.         switch (evt.id)
  76.         {
  77.             case Event.WINDOW_DESTROY: System.exit(0); return true;
  78.             default: return super.handleEvent(evt);
  79.         }             
  80.     }
  81. }
  82.