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);
}
}
Unable to Get Picture to Appear in Applet upon Running
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- Nicholas Jordan
- Posts: 124
- Joined: Mon Dec 20, 2004 12:33 am
- Location: Central Texas ISO Latin-1
- Contact:
change method call order...
picture is painted then we setBackground, must happen other way probably.
Set background, draw picture. Should happen that way anyway.
Set background, draw picture. Should happen that way anyway.