// This example is from the book _Java in a Nutshell_ by David Flanagan. // Written by David Flanagan. Copyright (c) 1996 O'Reilly & Associates. // You may study, use, modify, and distribute this example for any purpose. // This example is provided WITHOUT WARRANTY either expressed or implied. import java.applet.*; // Don't forget these import statements! import java.awt.*; public class SecondApplet extends Applet { /** A demonstration of graphics, text, setting fonts, and loops.

This example is from the book _Java in a Nutshell_ by David Flanagan. Written by David Flanagan. Copyright (c) 1996 O'Reilly & Associates. You may study, use, modify, and distribute this example for any purpose. This example is provided WITHOUT WARRANTY either expressed or implied. */ static final String message="Hello World"; private Font font; /** Initialize the font used by drawString to Helvaetica, Bold, 48 point */ public void init() { font = new Font("Helvetica", font.BOLD, 48); }//init /** Selects a color of pink and fills an oval with it.

Select color Red and draws a series of Ovals of different widths,

Sets color and font and draws the message in th oval. */ public void paint(Graphics g) { g.setColor(Color.pink); g.fillOval(10,10,330,100); g.setColor(Color.red); for(int i=0; i<330; i+=30) g.drawOval(10+i,10,330-2*i,100); g.setColor(Color.black); g.setFont(font); g.drawString(message, 25, 80 ); }//paint /**When used as an application the main program creates the window in which the message is painted. */ public static void main(String args[]) { Frame f = new Frame("SecondApplet"); SecondApplet helloWorld = new SecondApplet(); helloWorld.init(); helloWorld.start(); f.add("Center", helloWorld); f.setSize(400, 200); f.setVisible( true); } }