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

  1. //
  2. // (C) Copyright 1995 - 1999 Microsoft Corporation.  All rights reserved.
  3. //
  4. import java.io.*;
  5.  
  6. import com.ms.ui.*;
  7. import com.ms.fx.*;
  8.  
  9. class JTreeNodeItem extends UIItem implements JTreeConsts
  10. {
  11.     public UIText prefix = null;
  12.     private String pkg = new String("");
  13.  
  14.     public JTreeNodeItem(String name)
  15.     {
  16.         super(null, name);
  17.     }
  18.  
  19.     public JTreeNodeItem(JTreeNodeInfo nodeinfo)
  20.     {
  21.         super(null, nodeinfo.name);
  22.  
  23.         if ( !((nodeinfo.type == HTI_CLS) || (nodeinfo.type == HTI_IFACE)) )
  24.             return;
  25.  
  26.         pkg = nodeinfo.pkg;
  27.  
  28.         prefix = new UIText("Java");
  29.         prefix.setFont(new FxFont("Helvetica", FxFont.BOLD, 12));
  30.         prefix.setBackground(new FxColor(127,170,212));
  31.         prefix.setForeground(new FxColor(0,42,127));
  32.  
  33.         int len = pkg.length();
  34.  
  35.         if ( len >= 9 ) {
  36.             String str = pkg.substring(0,9);
  37.             if (str.equalsIgnoreCase("java.awt.")) {
  38.                 prefix.setName("AWT");
  39.                 prefix.setForeground(new FxColor(127,153,0));
  40.             }
  41.             else if ( len >= 10 ) {
  42.                 str = pkg.substring(0,10);
  43.                 if ( str.equalsIgnoreCase("com.ms.ui.") ) {
  44.                     prefix.setName("UI");
  45.                     prefix.setForeground(new FxColor(170,42,0));
  46.                 }
  47.                 else if ( str.equalsIgnoreCase("com.ms.fx.") ) {
  48.                     prefix.setName("Fx");
  49.                     prefix.setForeground(new FxColor(212,127,0));
  50.                 }
  51.                 else if ( len >= 11 ) {
  52.                     str = pkg.substring(0,11);
  53.                     if ( str.equalsIgnoreCase("com.ms.awt.") ) {
  54.                         prefix.setName("awt");
  55.                         prefix.setForeground(new FxColor(51,153,0));
  56.                     }
  57.                     else if ( len >= 12 ) {
  58.                         str = pkg.substring(0,12);
  59.                         if ( str.equalsIgnoreCase("com.ms.util.") ) {
  60.                             prefix.setName("Util");
  61.                             prefix.setForeground(new FxColor(51,153,0));
  62.                         }
  63.                     }
  64.                 }
  65.             }
  66.         }
  67.     }
  68.  
  69.     public String getFullName() { return(pkg + super.getName()); }
  70. }
  71.  
  72.