
//Title:       System Properties
//Version:     
//Copyright:   Copyright (c) 1998
//Author:      Mikael Bonnier
//Company:     Orbin
//Description: Your description
package sysprop;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;
//import com.sun.java.swing.*;

//import com.sun.java.swing.UIManager;
public class SystemProperties extends Applet
{
   boolean isStandalone = false;
   String backColor;
   TextArea txtContents = new TextArea("", 0, 0, TextArea.SCROLLBARS_VERTICAL_ONLY);
   List lstProperties = new List();
//Get a parameter value

   public String getParameter(String key, String def)
   {
      return isStandalone ? System.getProperty(key, def) :
      (getParameter(key) != null ? getParameter(key) : def);
   }

   //Construct the applet

   public SystemProperties()
   {
   }
//Initialize the applet

   public void init()
   {
      try
      {
         backColor = this.getParameter("backcolor", "C0C0C0");
         this.setBackground(new Color(Integer.parseInt(backColor, 16)));
      }
      catch(Exception e)
      {
         e.printStackTrace();
         this.setBackground(new Color(0xC0C0C0));
      }
      try
      {
      jbInit();
      }
      catch (Exception e)
      {
      e.printStackTrace();
      }
   }
   //static {
   //  try {
   //    //UIManager.setLookAndFeel(new com.sun.java.swing.plaf.metal.MetalLookAndFeel());
   //    //UIManager.setLookAndFeel(new com.sun.java.swing.plaf.motif.MotifLookAndFeel());
   //    UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
   //  }
   //  catch (Exception e) {}
   //}
//Component initialization

   private void jbInit() throws Exception
   {
      this.setLayout(null);
      this.setSize(400,300);
      txtContents.setBounds(new Rectangle(173, 63, 208, 181));
      lstProperties.setBounds(new Rectangle(19, 63, 141, 181));
      lstProperties.addItemListener(new java.awt.event.ItemListener()
      {
         public void itemStateChanged(ItemEvent e)
         {
            lstProperties_itemStateChanged(e);
         }
      });
      Enumeration props;
      try
      {
         props = System.getProperties().propertyNames();
      }
      catch(Exception e)
      {
         System.out.println("Exception: " + e);
         String a[] = {"file.separator", "browser", "browser.vendor",
         "browser.version", "java.class.version", "java.vendor",
         "java.vendor.url", "java.version", "line.separator",
         "os.arch", "os.name", "os.version", "path.separator"};
         Vector v = new Vector();
         for(int i=0; i<a.length; ++i)
            v.addElement(a[i]);
         props = v.elements();
      }
      String s;
      while(props.hasMoreElements())
      {
         s = (String)props.nextElement();
         lstProperties.add(s);
      }
      this.add(txtContents, null);
      this.add(lstProperties, null);
   }
//Start the applet

   public void start()
   {
   }
//Stop the applet

   public void stop()
   {
   }
//Destroy the applet

   public void destroy()
   {
   }
//Get Applet information

   public String getAppletInfo()
   {
      return "System Properties, Copyright (C) 1998 by Mikael Bonnier, Lund, Sweden";
   }
//Get parameter info

   public String[][] getParameterInfo()
   {
      String pinfo[][] =
      {
         {"backcolor", "String", "Background color in hexadecimal: RRGGBB"},
      };
      return pinfo;
   }

   void lstProperties_itemStateChanged(ItemEvent e)
   {
      txtContents.setText(lstProperties.getSelectedItem() + ":\n"
         + System.getProperty(lstProperties.getSelectedItem()));
   }
}



