head 1.1; access; symbols; locks; strict; comment @# @; 1.1 date 97.11.09.01.23.12; author kowallik; state Exp; branches; next ; desc @@ 1.1 log @Initial revision @ text @// main applet which sets up main window and calls all the other classes import java.applet.Applet; import java.awt.*; import java.util.*; import java.lang.*; public class main extends Applet { Button four, avst; T_Graph time; P_Graph phase; graphic out; // the pendulum itself animation doit; // thread for animation Control_Win control; // the extra frame with controls Welcome hello; // create layout for main window, open window with controls public void setup() { GridBagLayout glb = new GridBagLayout(); setLayout(glb); out = new graphic(); time = new T_Graph(); phase = new P_Graph(); four = new Button("Power Spectrum"); avst = new Button("Angle vs. Time"); GridBagConstraints c=new GridBagConstraints(); c.gridx=0; c.gridy=0; c.gridwidth=10; c.gridheight=10; c.weightx=1; c.weighty=1; c.fill=GridBagConstraints.BOTH; add(out); glb.setConstraints(out, c); c.gridx=10; add(phase); glb.setConstraints(phase, c); c.gridwidth=20; c.gridx=0; c.gridy=10; add(time); glb.setConstraints(time, c); c.gridheight=1; c.gridwidth=10; c.gridx=0; c.gridy=21; c.weightx=1.0; c.weighty=0.1; c.fill=GridBagConstraints.HORIZONTAL; add(avst); glb.setConstraints(avst, c); c.gridx=10; c.fill=GridBagConstraints.HORIZONTAL; add(four); glb.setConstraints(four, c); control= new Control_Win(this); control.show(); show(); } // executed once when Applet is loaded public void init() { hello = new Welcome(this); hello.show(); } // executed when Applet is started public void start() { setup(); } public void stop() { if(control != null) { control.exit(); control.dispose(); } if (hello!=null) { hello.dispose(); hello = null; } phase.exit(); time.exit(); this.removeAll(); doit = null; java.lang.System.gc(); } public String getAppletInfo() { return("Animation of complicated behavior of a damped, driven pendulum\n" + "\twritten by\n\tHans Kowallik (kowallik@@sdsc.edu) \n" + "copyright: Hans Kowallik \n"); } public boolean handleEvent(Event evt) { switch(evt.id) { case Event.ACTION_EVENT: if(evt.target==avst) { try { if(!control.doit.isAlive()) { time.drawcom(); return true; } }catch (NullPointerException npe) {} } if(evt.target==four) { try { if(!control.doit.isAlive()) { time.fdrawall(); return true; } }catch (NullPointerException npe) {} } } return false; } } @