I must be an idiot. I am working my way through a tutorial
java.sun.com/.../pa
ge6.jsp
and everything was going fine until the part where we add an image
and some text to a JLabel. The text is displaying fine, the image is
simply not displaying. No error on compile, just no image.
Yes, I have verified the image is in the same folder as the .class
file...code is:
package divelog;
/**
* This class creates the content on the
* Welcome tabbed pane in the Dive Log
* application.
* @version 1.0
*/
import javax.swing.*; //imported for buttons, labels, and images
import java.awt.*; //imported for layout manager
public class Welcome extends JPanel
{ //Opening class
// Variables for objects
private JLabel jl;
private JTextArea ta;
private JLabel diver;
public Welcome()
{ // Opens constructor
jl = new JLabel("test", new ImageIcon("diveflag.gif"), JLabel.CENTER);
jl.setFont(new Font("Times-Roman",
Font.BOLD, 17));
jl.setBackground(Color.blue);
setLayout(new BorderLayout());
add(jl,BorderLayout.CENTER);
} // Closes constructor
}//Closes class Welcome
//end code
The text behaves as expected - but no image at all.
What in the world am I doing wrong? This seems like such a simple
thing...