home *** CD-ROM | disk | FTP | other *** search
/ Chip Special: HTML & Java / Chip-Special_1997-01_HTML-a-Java.bin / javasdk / sdk-java.exe / SDKJava.cab / Samples / Version / SystemVersionPanel.java < prev    next >
Encoding:
Java Source  |  1996-10-10  |  1.5 KB  |  69 lines

  1. // SystemVersionPanel.java
  2. //
  3. // Created 09/25/96
  4. //
  5. // (C)Copyright 1996 Microsoft Corporation, All rights reserved.
  6. //
  7.  
  8. import java.awt.*;
  9. import java.util.*;
  10. import com.ms.util.*;
  11.  
  12. public
  13. class SystemVersionPanel extends Panel
  14. {
  15.     protected List items;
  16.     protected VersionPanel verpanel;
  17.  
  18.     private void add (Component comp, GridBagConstraints constraints)
  19.     {
  20.         ((GridBagLayout)getLayout()).setConstraints(comp,constraints);
  21.         super.add(comp);
  22.     }
  23.     
  24.     public SystemVersionPanel ()
  25.     {
  26.         GridBagLayout grid = new GridBagLayout();
  27.         setLayout(grid);
  28.  
  29.         GridBagConstraints c = new GridBagConstraints();
  30.         c.fill = GridBagConstraints.BOTH;
  31.         c.weightx = 1;
  32.         c.weighty = 1;
  33.     
  34.         items = new List();
  35.         add(items,c);
  36.         verpanel = new VersionPanel();
  37.         add(verpanel,c);
  38.  
  39.         Enumeration e;
  40.         try
  41.         {
  42.             e = SystemVersionManager.enumerate();
  43.         }
  44.         catch (Throwable th)
  45.         {
  46.             // No system version manager
  47.             return;
  48.         }
  49.  
  50.         while (e.hasMoreElements())
  51.         {
  52.             String compname = (String)e.nextElement();
  53.             items.addItem(compname);
  54.         }
  55.     }
  56.  
  57.     public boolean handleEvent (Event e)
  58.     {
  59.         if (e.id == Event.LIST_SELECT)
  60.         {
  61.             verpanel.changeInfo(SystemVersionManager.getSystemComponentVersion(items.getItem(items.getSelectedIndex())));
  62.             return true;
  63.         }
  64.  
  65.         return false;
  66.     }
  67. }
  68.  
  69.