import java.awt.*;
import java.applet.*;


public class JavaVersion extends Applet {
TextArea ta;
String version, vendor;
boolean warningFrame = false;  // we do not open a frame by default
boolean javaEnabled = false;

public void init() {
  version = System.getProperty("java.version");
  vendor = System.getProperty("java.vendor");
  String text = vendor +"\n";
  text += "Java " +  version;
  text += " / " + System.getProperty("os.arch")+ " " + System.getProperty("os.name")+ " " + System.getProperty("os.version") + "\n";
  text += "=================================\n";

  if (version.indexOf("1.")>=0) 
    javaEnabled=true;

  if (javaEnabled) {
    try {   // let's try to run some Java code
       Point p=new Point();
       this.addMouseListener(null);
    } catch (Throwable t)
    {
      t.printStackTrace(System.out);
      javaEnabled = false;
    }
  }
  if (!javaEnabled) {
    text += "Your browser does not support Java 1.1";
    setBackground(Color.red);
    warningFrame=true;   /* we cannot match the substring "1." in the string
                            that corresponds to a version of Java. */
  }
  else {
    text += "Your browser supports Java 1.1.";
    setBackground(Color.green);
  }

  setLayout(new BorderLayout());   // this applet uses BorderLayout.
  ta = new TextArea(text);
  ta.setEditable(false);   // user should not edit the text. 
  this.add("Center",ta);   // TextArea "ta" will occupy the central region.

}

public void start() {   // this can be useful for debugging 
  if (!warningFrame)
    return ;
  warningFrame = false;
  
  Frame myFrame = new Frame("Diagnostics");
  myFrame.setLayout( new FlowLayout(FlowLayout.CENTER, 20,20) );
  String result = "This browser does not support Java 1.1!";
  Label l = new Label(result, Label.CENTER);
  l.setBackground(Color.red);
  myFrame.setBackground(Color.red);
  myFrame.add("Center",l);
  myFrame.pack();
  myFrame.show();
  myFrame.toFront();
  try {
     Thread.sleep(3000);
  } catch (Exception e) {}
  myFrame.dispose(); 
}

}