Creating an Applet
This hour’s first project is an applet that displays the string “Saluton mondo!”, the traditional Esperanto greeting that is becoming more traditional by the hour. You get a feel for how applets are structured by re-creating the Saluton application from Hour 2, “Writing Your First Program,” as a program that can run on a web page.
Create a new empty Java file called SalutonApplet, enter the text from Listing 17.1 into the file, and save the file.
Listing 17.1. The Full Text of SalutonApplet.java
1: import java.awt.*; 2: 3: public class SalutonApplet extends javax.swing.JApplet { 4: String greeting; 5: 6: public void init() { 7: greeting = "Saluton mondo!"; 8: } 9:10: public void paint(Graphics screen) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access