Jake Byman
Jake Byman

Reputation: 563

Displaying an image to a JApplet?

I had a question about how to display a simple image to a JApplet. For some reason nothing shows up when I run this code:

import java.applet.Applet;
import java.awt.Image;
import java.awt.*;
import javax.swing.*;


public class Main extends JApplet{

Image backgroundFile;
public void init(){
    setSize(1500,750);
    backgroundFile = getImage(getCodeBase(), "Background.jpg");
}
public void paint(Graphics g){
    g.drawImage(backgroundFile, 20, 20, this);
}
}

It's not as if the code throws an error or something (that would be much more preferable!), rather nothing appears on the screen.

Upvotes: 1

Views: 771

Answers (1)

Jake Byman
Jake Byman

Reputation: 563

Thanks guys! That was exactly it. I feel so stupid, it just wasn't in the bin folder, rather the main project directory! :P Silly mistake, but thanks again!

Upvotes: 1

Related Questions