import java.awt.*; public class Controls extends java.awt.Panel{ // Builds up user interface panel private Button start,stop; private Label v; private TextField totalE; private Simulation simref; private Earthquake appletref; // Constructor for Controls Controls(Earthquake ref0, Simulation ref){ start = new Button("Go"); stop = new Button("Pause"); v= new Label("Total Energy = "); totalE = new TextField("0.0",6); add(start); add(stop); add(v); add(totalE); setBackground(Color.yellow); simref=ref; appletref=ref0; } private double myformat(double x, int n){ double d; int i; d=x*n; i=(int)d; d=(double)i/(double)n; return(d); } public void addToBox(double te){ totalE.setText(String.valueOf(myformat(te,10000))); } // Watch for button clicks and suspend/resume simulation thread // accordingly // also text box stuff public boolean action(Event evt, Object arg){ double dx; if(evt.target instanceof Button){ if(arg.equals("Pause")) appletref.runner.suspend(); else if(arg.equals("Go")) appletref.runner.resume(); return true; } return false; } }