//****************************************************************************** // Test1.java: Applet // //****************************************************************************** import java.applet.*; import java.awt.*; //============================================================================== // Main Class for applet Test1 // //============================================================================== public class Test1 extends Applet implements Runnable { // THREAD SUPPORT: // m_Test1 is the Thread object for the applet //-------------------------------------------------------------------------- private Thread m_Test1 = null; // ANIMATION SUPPORT: // m_Graphics used for storing the applet's Graphics context // m_Images[] the array of Image objects for the animation // m_nCurrImage the index of the next image to be displayed // m_ImgWidth width of each image // m_ImgHeight height of each image // m_fAllLoaded indicates whether all images have been loaded // NUM_IMAGES number of images used in the animation //-------------------------------------------------------------------------- private Graphics m_Graphics; private Image m_Images[]; private int m_nCurrImage; private int m_nImgWidth = 0; private int m_nImgHeight = 0; private boolean m_fAllLoaded = false; private final int NUM_IMAGES = 18,xsize=600,ysize=350,xoff=50,yoff=50,dx=7,dy=7; private int last_x=50; private int last_y=400,last_my,last_mmy; private int last_nny,nny; private boolean stop_toggle=false; private final int NSTEPS=50; private int[] ssn =new int[NSTEPS]; private int nstep,ni=5,enn=0,eus=0; // Test1 Class Constructor //-------------------------------------------------------------------------- public Test1() { // TODO: Add constructor code here } // APPLET INFO SUPPORT: // The getAppletInfo() method returns a string describing the applet's // author, copyright date, or miscellaneous information. //-------------------------------------------------------------------------- public String getAppletInfo() { return "Name: Test1\r\n" + "Author: Andrew Conway\r\n" + "Created with Microsoft Visual J++ Version 1.1"; } // The init() method is called by the AWT when an applet is first loaded or // reloaded. Override this method to perform whatever initialization your // applet needs, such as initializing data structures, loading images or // fonts, creating frame windows, setting the layout manager, or adding UI // components. //-------------------------------------------------------------------------- public void init() { // If you use a ResourceWizard-generated "control creator" class to // arrange controls in your applet, you may want to call its // CreateControls() method from within this method. Remove the following // call to resize() before adding the call to CreateControls(); // CreateControls() does its own resizing. //---------------------------------------------------------------------- resize(xsize, ysize); for(nstep=0;nstep=ni) { stop_toggle=true; m_Graphics.setColor(Color.red); m_Graphics.drawOval(xoff+nstep*10-dx/2,last_mmy-dy/2,dx,dy); last_my=last_mmy; m_Test1.suspend(); } } // TODO: Add additional thread-specific code here else Thread.sleep(50); } catch (InterruptedException e) { // TODO: Place exception-handling code here in case an // InterruptedException is thrown by Thread.sleep(), // meaning that another thread has interrupted this one stop(); } } } // MOUSE SUPPORT: // The mouseDown() method is called if the mouse button is pressed // while the mouse cursor is over the applet's portion of the screen. //-------------------------------------------------------------------------- public boolean mouseDown(Event evt, int x, int y) { double fenn,feus; if(stop_toggle) { if(y>yoff && y<=ysize-yoff-dy/2 && nstepyoff && y<=ysize-yoff-dy/2 && nstep