home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-06-17 | 3.1 KB | 98 lines |
- //******************************************************************************
- // HelloAuto.java: Applet
- //
- //******************************************************************************
- import java.applet.*;
- import java.awt.*;
-
- //==============================================================================
- // Main Class for applet HelloAuto
- //
- //==============================================================================
- public class HelloAuto extends Applet
- {
- // user defined data
- private int m_nInitCnt;
- private int m_nStartCnt;
- private int m_nStopCnt;
- private int m_nDestroyCnt;
-
- // HelloAuto Class Constructor
- //--------------------------------------------------------------------------
- public HelloAuto()
- {
- m_nInitCnt = 0;
- m_nStartCnt = 0;
- m_nStopCnt = 0;
- m_nDestroyCnt = 0;
- }
-
- // APPLET INFO SUPPORT:
- // The getAppletInfo() method returns a string describing the applet's
- // author, copyright date, or miscellaneous information.
- //--------------------------------------------------------------------------
- public String getAppletInfo()
- {
- return "Name: HelloAuto\r\n" +
- "Author: Stephen R. Davis\r\n" +
- "Created for Learn Java Now (c)";
- }
-
-
- // 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()
- {
- resize(320, 240);
-
- m_nInitCnt++;
- }
-
- // Place additional applet clean up code here. destroy() is called when
- // when you applet is terminating and being unloaded.
- //-------------------------------------------------------------------------
- public void destroy()
- {
- m_nDestroyCnt++;
- }
-
- // HelloAuto Paint Handler
- //--------------------------------------------------------------------------
- public void paint(Graphics g)
- {
- g.drawString("Hello, world", 0, 10);
- g.drawString("Init count = " + m_nInitCnt, 0, 20);
- g.drawString("Start count = " + m_nStartCnt, 0, 30);
- g.drawString("Stop count = " + m_nStopCnt, 0, 40);
- g.drawString("Destroy count = " + m_nDestroyCnt, 0, 50);
- }
-
- // The start() method is called when the page containing the applet
- // first appears on the screen. The AppletWizard's initial implementation
- // of this method starts execution of the applet's thread.
- //--------------------------------------------------------------------------
- public void start()
- {
- m_nStartCnt++;
- }
-
- // The stop() method is called when the page containing the applet is
- // no longer on the screen. The AppletWizard's initial implementation of
- // this method stops execution of the applet's thread.
- //--------------------------------------------------------------------------
- public void stop()
- {
- m_nStopCnt++;
- }
-
-
-
-
- // TODO: Place additional applet Code here
-
- }
-