/** * HelloFromVenus.java * * An applet program that displays a greeting * message from Venus graphically. It consists of a * text message and an image of the planet Venus */ import java.awt.*; import java.applet.Applet; public class HelloFromVenus extends Applet { public void paint (Graphics g) { // get dimensions of rectangular region for the applet Dimension d = getSize(); // set the pen color to black g.setColor (Color.black); // fill entire region with black color (paint the background) g.fillRect (0,0,d.width,d.height); // set the font to Helvetica, boldface style, and 24-point size g.setFont (new Font("Helvetica", Font.BOLD, 24)); // set the pen color to gold (see text p.99 for other colors) g.setColor (new Color(255, 215, 0)); // gold color // draw the text message at the top in gold color g.drawString ("Hello From Venus!", 40, 25); // draw the image of the planet Venus below the message. g.drawImage ( getImage(getCodeBase(), "Venus.gif"), 20, 60, this); } }