Create a file MyFirstApplet.java
Compile it in command prompt:
javac MyFirstApplet.java

Create a HTML file MyFirstApplet.html, embed MyFirstApplet.class inside.
Open MyFirstApplet.html in browser.

1
2
3
4
5
6
7
8
9
10
| 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.
1
2
3
4
5
6
7
8
9
10
11
12
| < 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