Unable to Get Picture to Appear in Applet upon Running

Using the Java SDK with TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
vajrapani
Posts: 1
Joined: Tue Sep 02, 2008 4:44 pm

Unable to Get Picture to Appear in Applet upon Running

Post by vajrapani »

According to my text, this example should show a picture of a smile in the upper left corner. However when I run the Applet, the picture doesn't show. Does anyone have any suggestions?



/*
Chapter 2: Welcome to My Day
Programmer: Lori Macdonald
Date: September 2, 2008
Filename: WelcomeApplet.java
Purpose: This project displays a welcome message, the user's name, and the system date in an applet.
*/

import java.util.Date;
import java.awt.*;
import java.applet.*;

public class WelcomeApplet extends Applet

{
public void paint(Graphics g)
{
Date currentDate = new Date(); // Date constructor
g.drawString("Welcome to My Day!",200,70);
g.drawString("Daily planner for Lori Macdonald",200,100);
g.drawString(currentDate.toString(),200,130);
Image smile; // declare an Image Object
smile = getImage(getDocumentBase(), "Smile.gif");
g.drawImage(smile,10,10,this);
setBackground(Color.yellow);
}
}
User avatar
Nicholas Jordan
Posts: 124
Joined: Mon Dec 20, 2004 12:33 am
Location: Central Texas ISO Latin-1
Contact:

change method call order...

Post by Nicholas Jordan »

picture is painted then we setBackground, must happen other way probably.

Set background, draw picture. Should happen that way anyway.
Post Reply