import java.awt.*; public class Controls extends java.awt.Panel{ // Builds up user interface panel private Label coupling; private Label descrip; private Scrollbar myscroll; private Button start,stop; private Ising appletref; // Constructor for Controls Controls(Ising ref){ coupling = new Label("0.00"); descrip = new Label("Inv. Temp"); myscroll = new Scrollbar(Scrollbar.HORIZONTAL,0,0,0,100); start = new Button("Resume"); stop = new Button("Pause"); add(descrip); add(coupling); add(myscroll); add(start); add(stop); setBackground(Color.pink); appletref = ref; } // Override handleEvent() to process scrollbar changes public boolean handleEvent(Event evt){ if(evt.target instanceof Scrollbar){ int v = ((Scrollbar)evt.target).getValue(); // propagate the new coupling to the simulation object appletref.simulation.beta=(double)v/100.0; // change it on screen coupling.setText(String.valueOf((double)v/100.0)); return true;} else return super.handleEvent(evt); } // Watch for button clicks and suspend/resume simulation thread // accordingly public boolean action(Event evt, Object arg){ if(evt.target instanceof Button){ if(arg.equals("Pause")) appletref.runner.suspend(); else if(arg.equals("Resume")) appletref.runner.resume(); return true;} else return false; } }