Original Post
[font=comic sans ms,cursive]Hi guys, I have encountered a problem with my code i am using to try and get a image to display on the screen.[/font]
Hi guys, I have encountered a problem with my code i am using to try and get a image to display on the screen.[/font]
[font=comic sans ms,cursive]I am using the Netbeans 7.0.1 IDE and the newest version of JDK.[/font]
[font=comic sans ms,cursive]This is my Code:[/font]
[Source Java]
import javax.swing.*;
import java.awt.*;
public class ShowImage extends JApplet
{
private Image image;
public void init()
{ image = getImage( getDocumentBase(), "nebula.jpg"); }
public void paint(Graphics g)
{ g.drawImage(image, 0, 0, this); }
}
[font=comic sans ms,cursive]The code doesn't come up with any errors or issues itself, the applet window appears when I run the code but no image is displayed, so I think it is something to do with where the image is placed. I shall include some screencaps to help you out. All help is appreciated, Thanks.[/font]
Ok Images wont upload so I will have to explain. The image and is in the Directory C:\Users\Ash\Documents\NetBeansProjects\Displaying an Image\src\nebula.jpg. This is also where the .java file is stored.
[font=comic sans ms,cursive]