The Java Program: Tiny.java
1 // Tiny.java -- applet and application
2
3 /*
4 Example of how to use this applet in an HTML file:
5 <applet code="Tiny" width=10 height=10></applet>
6 */
7
8 import java.applet.Applet;
9 import java.awt.Frame;
10 import java.awt.Graphics;
11 import java.awt.event.*;
12
13 public class Tiny extends Applet {
14
15 public void paint (Graphics g) {
16 g.drawLine (1,1,9,9);
17 }
18
19 // Static, stand-alone application stuff
20
21 static private Frame f;
22 static private Tiny b;
23
24 public static void main (String[] args) {
25 b = new Tiny();
26 b.setSize (10, 10);
27 b.init(); b.start();
28
29 f = new Frame ("Tiny");
30 f.add (b);
31 class WindowClosingListener extends WindowAdapter {
32 public void windowClosing (WindowEvent evt) { close(); }
33 }
34 f.addWindowListener (new WindowClosingListener ());
35 f.show();
36 }
37
38 static void close () {
39 f.setVisible (false);
40 b.stop(); b.destroy();
41 f.dispose();
42 System.exit(0);
43 }
44 }