Hi. I am trying to display a JFrame containing a JLabel with an image, and I can't get the image to display. The text appears fine.

I've done this before with no problem, so I have no idea what is wrong. I've tried everything I can think of to fix it.

import java.awt.Dimension;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Main
{
	public static void main( String[] args ) 
	{
		JFrame frame = new JFrame( "VN" );
		JLabel image = new JLabel( "hello", new ImageIcon( "vn1.bmp" ), JLabel.LEFT );
		
		image.setPreferredSize( new Dimension( 720, 460 ) );
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		
		frame.getContentPane().add( image );
		frame.pack();
		frame.setVisible( true );
	}
}

Thank you.

huuuh, sure you are right

ensure I forgot about it, if you would read it, so it would not be here this post

maybe someone...., I'm out of this post

This article has been dead for over six months. Start a new discussion instead.