Fachportal Physik des Landesbildungsservers Baden-Württemberg

thinLens.jad

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

public class thinLens extends Applet
{

public void init()
{
setBackground(bgColor);
for(int i = 0; i < STR.length; i++)
if((rts = getParameter(STR[i])) != null)
STR[i] = new String(rts);

String s;
if((s = getParameter("buttonText")) != null)
buttonText = s;
if((s = getParameter("windowTitle")) != null)
windowTitle = s;
if((s = getParameter("windowWidth")) != null)
windowWidth = Integer.parseInt(s);
if((s = getParameter("windowHeight")) != null)
windowHeight = Integer.parseInt(s);
if((s = getParameter("autoStart")) != null)
{
m = new LensWindow(windowTitle, true, STR);
go();
}
add(new Button(buttonText));
}

private void go()
{
m.resize(windowWidth, windowHeight);
m.show();
m.start();
}

public boolean action(Event event, Object obj)
{
if((event.target instanceof Button) && ((String)obj).equals(buttonText))
m = new LensWindow(String.valueOf(++windowCount) + ":" + windowTitle, true, STR);
go();
return true;
}

public static void main(String args[])
{
(new thinLens()).begin();
}

private void begin()
{
m = new LensWindow(windowTitle, false, STR);
go();
}

public thinLens()
{
buttonText = "start";
windowTitle = "Thin Lens demonstration by Fu-Kwun Hwang(1996)";
windowWidth = 600;
windowHeight = 350;
windowCount = 0;
bgColor = new Color(200, 223, 208);
}

String buttonText;
String windowTitle;
int windowWidth;
int windowHeight;
LensWindow m;
int windowCount;
Color bgColor;
String rts;
String STR[] = {
"Reset", "p", "q", "f", "m", "lens", "mirror", "Paraxial"
};
}