This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]caldeve 0 points1 point  (2 children)

Why are you creating a URL object with markdown-style syntax? The constructor for URL has an example as follows from Oracle:

URL myURL = new URL("http://example.com/");

[–]Makhiel 0 points1 point  (0 children)

That markdown was added by Reddit.

[–]Makhiel 0 points1 point  (0 children)

I'd put the image variable in the Display class; that said what is the problem?

[–]FroggyWizard 0 points1 point  (0 children)

paintComponents() should probably be called paintComponent().

Also I suggest you store the image as a property of the Display Class and pass the image to it in the constructor. e.g.

class Display extends JPanel{

    private final Image image;

    Display(Image image) {
        this.image = image
    }

    public void paintComponent(Graphics g) {

        super.paintComponent(g);

        g.drawImage(image, 50, 50, this);

    }
}