0

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();
    }
}
2
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by Seldar
0

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

0

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");
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.