/******************************************************************************
*  My third Java applet program to print Hello and name                           
*  Applet takes a name from the <param> tag within the <applet> tag in HTML
*  The <param> is populated by entering a value after the URL?
******************************************************************************/
import javax.swing.JApplet;
import java.awt.*;

public class HelloApplet4 extends JApplet {

    private String name  = "";
    private String error = "";

    public void init( )                         //Automatically called by Applet 
    {
        name = getParameter("message");         //get name from html message param

        if (name != null)                       //if a name was sent by html
            name  = "Hello " + name;            //  append Hello before name
        else                                    //otherwise
            name  = "Hello nobody";             //  Hello nobody    
            
//      error = "Enter your name after URL?";   //  error message

        setBackground(Color.black);
        setForeground(Color.white);
        setFont(new Font("Arial", Font.BOLD, 20));
    }

    public void paint(Graphics g)               //Automatically called by init() 
    {       
        g.drawString(name,  20, 90);            //write name at pixel x=20 y=90 
        g.drawString(error, 20, 120);           //write error message
    }
}