home *** CD-ROM | disk | FTP | other *** search
/ Learn Java Now / Learn_Java_Now_Microsoft_1996.iso / JavaNow / Code / Chap12 / HelloAuto2 / HelloAuto.class (.txt) next >
Encoding:
Java Class File  |  1996-07-29  |  1.6 KB  |  39 lines

  1. import java.applet.Applet;
  2. import java.awt.Graphics;
  3.  
  4. public class HelloAuto extends Applet {
  5.    private int m_nInitCnt = 0;
  6.    private int m_nStartCnt = 0;
  7.    private int m_nStopCnt = 0;
  8.    private int m_nDestroyCnt = 0;
  9.  
  10.    public void start() {
  11.       ++this.m_nStartCnt;
  12.    }
  13.  
  14.    public void stop() {
  15.       ++this.m_nStopCnt;
  16.    }
  17.  
  18.    public String getAppletInfo() {
  19.       return "Name: HelloAuto\r\n" + "Author: Stephen R. Davis\r\n" + "Created for Learn Java Now (c)";
  20.    }
  21.  
  22.    public void destroy() {
  23.       ++this.m_nDestroyCnt;
  24.    }
  25.  
  26.    public void init() {
  27.       ((Applet)this).resize(320, 240);
  28.       ++this.m_nInitCnt;
  29.    }
  30.  
  31.    public void paint(Graphics g) {
  32.       g.drawString("Hello, world", 0, 10);
  33.       g.drawString("Init count    = " + this.m_nInitCnt, 0, 20);
  34.       g.drawString("Start count   = " + this.m_nStartCnt, 0, 30);
  35.       g.drawString("Stop count    = " + this.m_nStopCnt, 0, 40);
  36.       g.drawString("Destroy count = " + this.m_nDestroyCnt, 0, 50);
  37.    }
  38. }
  39.