/** MyApplet3.java: Third Hello World Applet ** If this applet finds a name on the web ** page, then it says hello using this name. ** Otherwise, it says hellow to Dude. ** Assignment: Modify this file by changing ** the if-statement and text, so that two ** different greetings are given depending on ** whether or not a name is found on the web ** page. ** Also, take a look at the MyApplet3.html ** webpage file for displaying this applet. ** Change the name value on this page and ** verify that your java program works. **/ /** USE EXISTING JAVA CLASSES **/ import java.awt.*; import java.applet.Applet; public class MyApplet3 extends Applet { Font f = new Font("TimesRoman", Font.BOLD, 36); String name; // Define a string variable String message; // to store the name specified // on the webpage, and one for public void init() // your message. { name = getParameter("name"); // Get the name on the webpage, if (name == null) name = "Dude"; // if there is one. message = "Hello " + name + "!"; } public void paint(Graphics g) { g.setFont(f); g.setColor(Color.red); g.drawString(message, 5, 40); } }