//******************************************************************** // Class Name: HelloApplet2 // Assignment: Lab #2, The (in)famous Hello World program as an Applet // // Author Name: Your Name REPLACE with YOUR info // Email: youremail@calpoly.edu and ADD your name to // URL: www.calpoly.edu/~yourlogin/ the HISTORY below if // UNIX home: /home/yourpath/yourhomedir you make any CHANGES. // // Course: CSC/CPE 101 ALSO update these // Section: Prof Scheftic's lines with your // Term: ongoing own specific information // School: California Polytechnic State University // Address: San Luis Obispo, CA 93407 USA // // History: // A long time ago original version by an unknown author // 3/20/2000 Java version prepared for CSC 101, M. Liu // 6/21/2000 comments extended for CSC 101, E. Rogers // 1/14/2001 comments modified for CSC/CPE-101, C. Scheftic: // expanded for use with current course template //******************************************************************** // // Program Description and Design Overview: // This applet generates the proverbial programmer's test message: // "Hello World!" // // Input Requirements: // None. // // Output Requirements: // First line: blank line // Second line: Hello, world! // Third line: blank line // // Variables Used: // final int FONT_SIZE // used to control size of entire on-screen message // set within program to 48 // note its pedagogical purpose: to illustrate use of a constant // Font font // used to control format of entire on-screen message // set within program to serif, bold, FONT_SIZE // // Imported Classes: // java.applet.* // java.awt.* // // Included Methods: // init() // paint(Graphics) // // Imported Methods: // drawString(String str, int x, int y) // Font(String name, int style, int size) // setBackground(Color) // setColor(Font) // setFont(Color) // // Program Assumptions: // None. // // Pending Problems: // None known as of 14 Jan 2001. // //******************************************************************** import java.applet.*; import java.awt.*; public class HelloApplet2 extends Applet { public void init() { setBackground(Color.yellow); } public void paint(Graphics g) { final int FONT_SIZE = 48; Font font = new Font("Serif", Font.BOLD, FONT_SIZE); g.setFont(font); g.setColor(Color.blue); g.drawString("Hello, world!", 75, 150); } // end paint } // end HelloApplet2