import java.applet.*; import java.awt.*; /** the classic first example from Kernighan & Richie C rewritten as an Applet @see Hello */ public class HelloWorld extends Applet { /** method called when applications is started. Does nothing in this case. */ public void init(){ }//init /** Method called whenever the applet needs to be painted or repainted. Outputs a string by painting it into its argument Graphics g */ public void paint(Graphics g) { //g.setColor(Color.pink); g.drawString("Hello world!", 50, 25); }//paint /**When used as an application the main program. main creates the window in which Helloworld runs. */ public static void main(String args[]) { Frame f = new Frame("HelloWorld");// window for applet to beput in HelloWorld helloWorld = new HelloWorld();//The applet helloWorld.init();//initialise applet. helloWorld.start();//start applet. f.add("Center", helloWorld);//put applet in middle of frame f.setSize(300, 300);// make frame big enough f.setVisible( true);//let the user see the result. }//main }//HeloWorld