drawing an image
im trying to learn java and im writing an applet to draw an image to the screen. It runs but no image appears any help appreciated, and i do have the image in the same directory as the class files
import java.applet.Applet;
import java.awt.*;// we need the awt to use the type Image
import javax.swing.*;
public class heresJohnny extends JApplet
{
private Image image;
public void init( )
{
image = getImage(getDocumentBase( ), "johnny.gif");
}
public void paint( Graphics g )
{
g.drawImage( image, 1, 1, this );
}
}
i checked the console and it just says
Java Plug-in 1.5.0_07
Using JRE version 1.5.0_07 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Liam
-
c:clear console window
f:finalize objects on finalization queue
g:garbage collect
h:display this help message
l:dump classloader list
m:print memory usage
o:trigger logging
p:reload proxy configuration
q:hide console
r:reload policy configuration
s:dump system and deployment properties
t:dump thread list
v:dump thread stack
x:clear classloader cache
0-5: set trace level to <n>
-
nothing of any use, at the bottom of the browser it says applet started and it compiles with no errors yet no image shows. i have also tried the suggested getCodeBase() as well but that did not work either. any ideas?