Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just a blank frame...no image diaplyed

Status
Not open for further replies.

eclipse33

Programmer
Apr 13, 2001
94
CA
Hi,

Just new to java...why is the image not displayed??
The image is the smae directory as the program.

Thanks in advance
eclipse33


import javax.swing.*;

public class Test {
public static void main(String[] args) {
JFrame f = new JFrame("Image test");

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add( new JLabel( new ImageIcon("jersey.jpg") ) );

f.setSize(500,500); f.setVisible(true);
}
}
 
I just tested your code and it seems to work fine when I put in my own image for "jersey.jpg". Perhaps there is a problem with your image?
 
Hey,

I tried another image and it worked fine....very weird! Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top