I dont understand why the image isnt appearing! please help..

 import javax.swing.*;
 import java.awt.*;
//import java.awt.event.*;

public class level2 extends JFrame{
Container con= getContentPane();
ImageIcon bg= new ImageIcon("D:\\Raptor\\background3.jpg");
JLabel back= new JLabel(bg);
level2(){
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(null);
    setSize(1300,700);
    back.setBounds(0,0,500,500);
    con.add(back);
    setVisible(true);
} 
    public static void main(String[] args) {

        new level2();
    }
}

My guess would be that the image is in a different folder from the one your java class is in.

My guess would be that the jpg (are you sure the file extension is right, might it be .jpeg, ikd ...) file lives in a directory that is outside of the scope of your java project. Try moving it to the same folder as your java class and don't specify the path to it, just do like :

ImageIcon bg = new ImageIcon("background3.jpg");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.