-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppletExample.java
More file actions
62 lines (53 loc) · 1.57 KB
/
Copy pathAppletExample.java
File metadata and controls
62 lines (53 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package java1.applets;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;
/**
* Java 1.0 Applet Example Demonstrates basic applet functionality
* NOTE: Applets are deprecated in modern Java. This is for historical reference.
*
* To run as applet, create HTML file:
* <applet code="AppletExample.class" width="300" height="200"></applet>
*/
public class AppletExample extends Applet
{
private String message = "Hello from Java 1.0 Applet!";
public void init()
{
System.out.println("Applet initialized");
setBackground(Color.WHITE);
setForeground(Color.BLUE);
}
public void start()
{
System.out.println("Applet started");
}
public void paint(Graphics g)
{
g.drawString(message, 50, 50);
g.drawRect(30, 30, 200, 100);
g.drawOval(100, 70, 50, 50);
}
public void stop()
{
System.out.println("Applet stopped");
}
public void destroy()
{
System.out.println("Applet destroyed");
}
// Can also run as standalone application
public static void main(String[] args)
{
System.out.println("=== Java 1.0 Applet Example ===\n");
System.out.println("Applets allow Java programs to run in web browsers.");
System.out.println("Lifecycle methods:");
System.out.println("- init(): Initialization");
System.out.println("- start(): Applet starts");
System.out.println("- paint(Graphics g): Drawing");
System.out.println("- stop(): Applet stops");
System.out.println("- destroy(): Cleanup");
System.out.println("\nNote: Applets are deprecated in modern Java.");
System.out.println("This example is for historical reference only.");
}
}