Class 1, Part 2 | Intro to Java 30-IT-396 |
Applet Example
import java.applet.Applet;
import java.awt.Graphics;
/**
*
* @author default
*/
public class TempConverter extends Applet {
float celciusTemp = 0.0F;
/** Initialization method that will be called
after the applet is loaded
* into the browser.
*/
public void init () {
// get our parameter.
String strTemp = getParameter("temp");
// We have to do this the odl fashioned way.
float fltTemp = new Float(strTemp).floatValue();
// covert
celciusTemp = (fltTemp - 32)*5/9;
}
public void paint(Graphics g) {
// send data to browser.
g.drawString("Celcius
temperature is: " + celciusTemp, 50, 25);
}
}
Created by: Brandan
Jones January 4, 2002