home *** CD-ROM | disk | FTP | other *** search
/ Computer Life: Multimedia Mega Pac / Multimedia_Mega-Pac_Computer_Life_1996.iso / hotjava / demo / classes / sampleap.jav < prev    next >
Text File  |  1995-05-19  |  3KB  |  98 lines

  1. /*
  2.  * @(#)SampleApplet.java    1.5 95/03/14 Arthur van Hoff
  3.  *
  4.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. import awt.Graphics;
  21. import browser.Applet;
  22.  
  23. /**
  24.  * A sample applet that shows off some features and
  25.  * prints lots of debugging statements.
  26.  * @author     Arthur van Hoff
  27.  * @version     1.5, 14 Mar 1995
  28.  */
  29. class SampleApplet extends Applet {
  30.     /**
  31.      * Applet methods
  32.      */
  33.     public void init() {
  34.     System.out.println("SampleApplet: init()");
  35.     resize(100, 100);
  36.     }
  37.     public void start() {
  38.     System.out.println("SampleApplet: start()");
  39.     }
  40.     public void stop() {
  41.     System.out.println("SampleApplet: stop()");
  42.     }
  43.     public void destroy() {
  44.     System.out.println("SampleApplet: destroy()");
  45.     }
  46.  
  47.     /**
  48.      * Paint a rectangle with some wierd lines...
  49.      */
  50.     public void paint(Graphics g) {
  51.     System.out.println("SampleApplet: paint()");
  52.     g.drawRect(0, 0, width - 1, height - 1);
  53.     for (int i = 0 ; i < width - 1 ; i += 8) {
  54.         g.drawLine(i, 0, width - 1, height - 1);
  55.     }
  56.     for (int i = 0 ; i < height - 1 ; i += 8) {
  57.         g.drawLine(0, 0, width - i, height - 1);
  58.     }
  59.     }
  60.  
  61.     /**
  62.      * Mouse methods
  63.      */
  64.     public void mouseDown(int x, int y) {
  65.     System.out.println("SampleApplet: mouseDown(" + x + "," + y + ")");
  66.     getFocus();
  67.     play("audio/beep.au");
  68.     }
  69.     public void mouseDrag(int x, int y) {
  70.     System.out.println("SampleApplet: mouseDrag(" + x + "," + y + ")");
  71.     }
  72.     public void mouseUp(int x, int y) {
  73.     System.out.println("SampleApplet: mouseUp(" + x + "," + y + ")");
  74.     }
  75.     public void mouseMove(int x, int y) {
  76.     System.out.println("SampleApplet: mouseMove(" + x + "," + y + ")");
  77.     }
  78.     public void mouseEnter() {
  79.     System.out.println("SampleApplet: mouseEnter()");
  80.     }
  81.     public void mouseExit() {
  82.     System.out.println("SampleApplet: mouseExit()");
  83.     }
  84.  
  85.     /**
  86.      * Focus methods
  87.      */
  88.     public void gotFocus() {
  89.     System.out.println("SampleApplet: gotFocus()");
  90.     }
  91.     public void lostFocus() {
  92.     System.out.println("SampleApplet: lostFocus()");
  93.     }
  94.     public void keyDown(int key) {
  95.     System.out.println("SampleApplet: keyDown(" + key + ")");
  96.     }
  97. }
  98.