home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / afc11 / JTreeVue / Src / JTreeVue.java < prev    next >
Encoding:
Java Source  |  2000-05-04  |  2.0 KB  |  91 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.     // Override requestFocus to throw focus back to tree if user switches to another
  52.     //  app and then returns to this one.
  53.     //
  54.     public void requestFocus()
  55.     {
  56.         jtree.requestFocus();
  57.     }
  58. }
  59.  
  60. // Application CODE
  61. class JTVFrame extends UIFrame
  62. {
  63.     private JTreeVuePanel jtree;
  64.  
  65.     public JTVFrame()
  66.     {
  67.         super("Java Class Hierarchy Application");
  68.         setBackground(FxColor.lightGray);
  69.         setLayout(new UIBorderLayout(0, 0));
  70.         setFont(new FxFont("Dialog", FxFont.BOLD, 12));
  71.  
  72.         try {
  73.             FileInputStream stream = new FileInputStream("tree.html");
  74.             jtree = new JTreeVuePanel(stream);
  75.             add(jtree, "Center");
  76.             setSize(350, 400);
  77.             setVisible(true);
  78.             jtree.objroot.getHeader().requestFocus();
  79.         } catch ( Exception e ) { e.printStackTrace(); }
  80.     }
  81.  
  82.     public boolean handleEvent(Event evt)
  83.     {
  84.         switch (evt.id)
  85.         {
  86.             case Event.WINDOW_DESTROY: System.exit(0); return true;
  87.             default: return super.handleEvent(evt);
  88.         }             
  89.     }
  90. }
  91.