package com.horstmann.labrat;

import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.JavaEnvUtils;

public class CheckFrame extends JFrame
{
   public CheckFrame()
   {
      JTextField field = new JTextField();
      JTextArea area = new JTextArea(30, 40);
      add(field, "North");
      add(new JScrollPane(area), "Center");

      String javac = JavaEnvUtils.getJdkExecutable("javac");
      area.append("jdkExecutable=" + javac + "\n");
      area.append("systemBootClasspath=" + Path.systemBootClasspath + "\n");
      area.append("systemClasspath=" + Path.systemClasspath + "\n");

      String[] keys = {
            "java.version", 
            "java.vendor",
            "java.vendor.url",
            "java.home",
            
                        "java.vm.specification.version",
                        "java.vm.specification.vendor",
                        "java.vm.specification.name",
                        "java.vm.version",
                        "java.vm.vendor",
                        "java.vm.name",
                        "java.specification.version",
                        "java.specification.vendor",
                        "java.specification.name",
                        "java.class.version",
                        "java.class.path",
                        "java.library.path",
                        "java.io.tmpdir",
                        "java.compiler",
                        "java.ext.dirs",                        
                        "os.name",
                        "os.arch",
                        "os.version",
                        "file.separator",
                        "path.separator",
                        "line.separator",
                        "user.name",
                        "user.home",
                        "user.dir"                        
      };

      for (int i = 0; i < keys.length; i++)
      {
         String key = keys[i];
         String value = System.getProperty(key);
         area.append(key + "=" + value + "\n");
      }
      if (javac != null)
      {
         field.setText("pass");
         field.setBackground(Color.green);
      }
      else
      {
         field.setText("fail");
         field.setBackground(Color.red);
      }
   }
}
