load and draw image

G

GEBUH

Hi all, I don't know diddly about java, so I started tinkering with applets and
already I hit something I can't figure out. I've borrowed a couple of books
and googled the crap outta the subject, but nothing I do seems to work.
I'm using Jcreator2.5LE compiler on my xp os. I can't get the image to
display. I even copied the code to do a simple image applet from a java
textbook- but that doesn't work either. can anyone help me?
here's my code:

import java.awt.*;
import java.applet.*;


public class HangMan extends Applet {

private Image scaffold = null;
private int width, height; //used for size of image

public void init()
{

width = getSize().width;
height = getSize().height;

scaffold = getImage(getDocumentBase(), "HangMan/reactions.gif");
//supposed to load image
//if this is done in paint, they will be redrawn everytime applet is
redrawn

}



public void paint(Graphics g)
{
g.drawString("HANGMAN", 220, 20 );
g.drawImage(scaffold, 0, 0, this);
/*if(!g.drawImage(scaffold, 0, 0, this))
{
g.drawString("Loading Picture. Please hang on",
220, 220);
} */
}

}

here's the html
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR="000000">
<CENTER>
<APPLET
code = "HangMan.class"
width = "600"
height = "400"
</APPLET>
</CENTER>
</BODY>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top