home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 14 / IOPROG_14.ISO / soft / sdkjava / sdkjava.exe / SDKJava.cab / AFC102 / Samples / AFCDetect / Src / AFCDetect.java next >
Encoding:
Java Source  |  1998-03-05  |  2.4 KB  |  109 lines

  1. //
  2. // (c) 1997 Microsoft Corporation.  All rights reserved.
  3. //
  4.  
  5. import java.applet.*;
  6. import java.awt.*;
  7.  
  8. /**
  9.  *    Small Java applet which detects whether AFC is installed on the machine or
  10.  *    not. The function doesSupportAFC() returns 1 if AFC is installed and 0
  11.  *    if not. Call this function from a piece of JavaScript and do the right
  12.  *    thing in that piece of code.
  13.  *
  14.  *    @version    1.0, 8/1/97
  15.  */
  16.  
  17. public class AFCDetect extends Applet
  18. {
  19.     public AFCDetect()
  20.     {        
  21.     }
  22.  
  23.     /**
  24.      *    Applet info.
  25.      *    @returns    String with information about the applet
  26.      */
  27.     public String getAppletInfo()
  28.     {
  29.         return "Name: AFCDetect\r\n" +
  30.                "Microsoft Corp.\r\n";
  31.     }
  32.  
  33.  
  34.     /**
  35.      *    The init() method is called by AWT when an applet is first loaded or
  36.      *    reloaded. Resizes the applet to 0 by 0 pixels since we want this
  37.      *    applet to run very subtly.
  38.      */
  39.     // 
  40.     public void init()
  41.     {
  42.         // we don't want this applet taking up any space on the screen
  43.          resize(0, 0);
  44.     }
  45.         
  46.     /**
  47.      *    Main function in the applet. Called by a piece of JavaScript and
  48.      *    returns whether AFC is supported on this machine or not. 
  49.      *    
  50.      *    @returns Return 0 if AFC is not installed, and 1 if it is
  51.      */
  52.     public int doesSupportAFC()
  53.     {
  54.         // Does this by trying to load an AFC UIComponent dynamically. If this succeeds,
  55.         // we have AFC. If not, we're out of luck.
  56.  
  57.         Class c = null ;
  58.         try
  59.             {
  60.  
  61.                 // try to load a UIComponent. This must always exist for AFC to work.
  62.                 c = Class.forName("com.ms.fx.FxColor");                
  63.             }
  64.         catch (ClassNotFoundException e)
  65.             {
  66.                 // afc NOT installed
  67.                 return 0;
  68.             }    
  69.         catch ( Exception e )
  70.             {
  71.                 return 0 ;
  72.             }
  73.     
  74.         // AFC installed
  75.         return 1;    
  76.     }
  77.     
  78.     /**
  79.      *    Obtain the full dot-separated version of AFC we're using in a string.
  80.      *    
  81.      *    @returns    Version of AFC; four fields, dot separated.
  82.      */
  83.     public String getAFCVersionString()
  84.         {
  85.             return AFCVersionManager.getPackageVersionFull("com.ms.ui");
  86.         }
  87.  
  88.     /**
  89.      *    Obtains the major version number of AFC.    
  90.      *    
  91.      *    @returns    AFC major version number
  92.      */
  93.     public int getAFCMajorVersion()
  94.         {
  95.             return AFCVersionManager.getPackageVersionMajor("com.ms.ui");
  96.         }    
  97.  
  98.     /**
  99.      *    Obtains the minor version number of AFC.    
  100.      *    
  101.      *    @returns    AFC minor version number
  102.      */
  103.     public int getAFCMinorVersion()
  104.         {
  105.             return AFCVersionManager.getPackageVersionMinor("com.ms.ui");
  106.         }    
  107.     
  108. }
  109.