import javax.swing.JApplet;
import java.awt.Graphics;
public class MyFirstApplet extends JApplet {
public void paint(Graphics g) {
g.drawString("Hello, Java-Buddy!", 50, 50);
}
}
Compile it in command prompt:
javac MyFirstApplet.java

Create a HTML file MyFirstApplet.html, embed MyFirstApplet.class inside.
<html>
<head>
<title> Java-Buddy </title>
</head>
<body>
<hr>
<applet code = "MyFirstApplet.class" width = 300 height = 300 >
</applet>
<hr/>
</body>
</html>
Open MyFirstApplet.html in browser.

No comments:
Post a Comment