import java.awt.*; import java.awt.event.*; public class MonoThread extends IcobjWorkspace { int preys = 50, predators = 2; TextField preyInput = new TextField(""+preys); TextField predatorInput = new TextField(""+predators); protected Thread mainThread; boolean started; public void init(){ super.init(); Button start = new Button("start"); start.addMouseListener(new StartAction(this)); Panel p = new Panel(); p.setBackground(Color.lightGray); setLayout(new BorderLayout()); p.setLayout(new GridLayout(1, 5, 5, 20)); add("South", p); p.add(start); p.add(new Label("#Preys: ",Label.RIGHT)); p.add(preyInput); p.add(new Label("#Predators: ",Label.RIGHT)); p.add(predatorInput); } protected void readParams(){ try{ preys = Integer.parseInt(preyInput.getText()); predators = Integer.parseInt(predatorInput.getText()); }catch(Exception e){} } protected void go(){ mainThread = new Thread(this); mainThread.start(); } public void startButtonPressed(){ if (started) return; started = true; readParams(); for(int i=0;i