import java.awt.*; import java.awt.event.*; import java.applet.*; import java.util.*; public class XYApplet extends Applet { public XY experiment; private Canvas canvas = new XYCanvas(this); private Choice linearDimension = new Choice(); private Button start = new Button("Start"); private Button step = new Button("Step"); private Button cont = new Button("Continue"); private Button stop = new Button("Stop"); private TextField temperature = new TextField("0.893", 6); private TextField field = new TextField("0", 6); private TextField angle = new TextField("1", 6); private TextField mctime = new TextField(4); private TextField mx = new TextField(5); private TextField my = new TextField(5); private TextField energy = new TextField(5); private TextField meanMx = new TextField(5); private TextField meanMy = new TextField(5); private TextField meanE = new TextField(5); // 'r' for running, 't' for taking a MC step, 's' for stop public char status = 's'; private int LChoices[] = {4, 8, 16, 32, 64, 128, 256}; public int L; private double T, H, dtheta; public void init() { setBackground(Color.white); setLayout(new BorderLayout()); Panel top = new Panel(); Panel bottom = new Panel(); top.setLayout(new FlowLayout()); bottom.setLayout(new FlowLayout()); for(int i=0; i<7; i++) linearDimension.addItem("" + LChoices[i]); top.add(new Label("L:")); top.add(linearDimension); top.add(new Label(" T:")); top.add(temperature); top.add(new Label(" H:")); top.add(field); top.add(new Label(" dtheta")); top.add(angle); top.add(start); top.add(step); top.add(cont); top.add(stop); add(top, BorderLayout.NORTH); bottom.add(new Label("t:")); bottom.add(mctime); bottom.add(new Label("Mx:")); bottom.add(mx); bottom.add(new Label("My:")); bottom.add(my);; bottom.add(new Label("E:")); bottom.add(energy); bottom.add(new Label(":")); bottom.add(meanMx); bottom.add(new Label(":")); bottom.add(meanMy); bottom.add(new Label(":")); bottom.add(meanE); add(bottom, BorderLayout.SOUTH); add(canvas, BorderLayout.CENTER); start.addActionListener(new StartListener()); step.addActionListener(new StepListener()); stop.addActionListener(new StopListener()); cont.addActionListener(new ContListener()); start.addMouseListener(new StartMouseAdapter()); step.addMouseListener(new StepMouseAdapter()); stop.addMouseListener(new StopMouseAdapter()); cont.addMouseListener(new ContMouseAdapter()); mctime.setEditable(false); mx.setEditable(false); my.setEditable(false); energy.setEditable(false); meanMx.setEditable(false); meanMy.setEditable(false); meanE.setEditable(false); L = 32; T = 1.5; H = 0; new MyThread().start(); } private double setPrecision(double val, int numDigits) { int scale = 1; for(int i=0; i