Hello World Example 2Solution//Purpose: To write a greetings "Hello World" inside of a web-page. // import java.awt.Graphics; //import the Graphics class import java.applet.Applet; //import the Applet class public class HelloWorld extends Applet { public Color color = new Color(0,255,255); //Note that g is the local Graphics object representing the //portion of the web-page designated for the applet when it //is included in HTML. //called when the contents of the component should be painted in //response to the component first being shown or damage needing repair. public void paint(Graphics g) { g.setColor( color ); g.drawString("Hello World!", 25, 25); //start at 25,25 pixel location for the baseline of the text } } Here is the applet: |