home *** CD-ROM | disk | FTP | other *** search
/ Java 1996 August / Java - Summer 1996.iso / windows / doc / applet / overview / betaclasses / simple.000 < prev    next >
Encoding:
Text File  |  1996-02-26  |  1.7 KB  |  75 lines

  1. <!--NewPage-->
  2. <html>
  3. <head>
  4. <title>Simple.java</title>
  5. </head>
  6. <body>
  7. <p>
  8. <hr size=4>
  9.  
  10. <h2>
  11.     Simple.java
  12. </h2>
  13. <p>
  14. <blockquote>
  15.  
  16. <pre>
  17.  
  18. /*
  19.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  20.  *
  21.  * Permission to use, copy, modify, and distribute this software
  22.  * and its documentation for NON-COMMERCIAL purposes and without
  23.  * fee is hereby granted provided that this copyright notice
  24.  * appears in all copies. Please refer to the file "copyright.html"
  25.  * for further important copyright and licensing information.
  26.  *
  27.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  28.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  29.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  30.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  31.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  32.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  33.  */
  34. import java.awt.Graphics;
  35.  
  36. public class Simple extends java.applet.Applet {
  37.  
  38.     StringBuffer buffer = new StringBuffer();
  39.  
  40.     public void init() {
  41.     resize(500, 20);
  42.         addItem("initializing... ");
  43.     }
  44.  
  45.     public void start() {
  46.         addItem("starting... ");
  47.     }
  48.  
  49.     public void stop() {
  50.         addItem("stopping... ");
  51.     }
  52.  
  53.     public void destroy() {
  54.     addItem("preparing for unloading...");
  55.     }
  56.  
  57.     public void addItem(String newWord) {
  58.     System.out.println(newWord);
  59.     buffer.append(newWord);
  60.     repaint();
  61.     }
  62.  
  63.     public void paint(Graphics g) {
  64.     g.drawRect(0, 0, size().width - 1, size().height - 1);
  65.     g.drawString(buffer.toString(), 5, 15);
  66.     }
  67. }
  68. </pre>
  69. </blockquote>
  70. <p>
  71. <hr size=4>
  72. <p>
  73. </body>
  74. </html>
  75.