Hi all,
Would anybody please tell me what might be wrong with the following lines of code:
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame{
private String name = "image.gif";
private Icon icon = new ImageIcon(name);
private JLabel label;
public Test(){
Container c = getContentPane();
c.setLayout( new FlowLayout() );
label = new JLabel(icon);
c.add(label);
setSize(800,600);
setVisible(true);
}
public static void main (String args[]) {
Test t = new Test(); t.setDefaultCloseOperationJFrame.EXIT_ON_CLOSE);
}
NOTE: the image is in the same directory of the java and class files.
This code should just show my picture, right?? then what might be wrong ??
Would anybody please tell me what might be wrong with the following lines of code:
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame{
private String name = "image.gif";
private Icon icon = new ImageIcon(name);
private JLabel label;
public Test(){
Container c = getContentPane();
c.setLayout( new FlowLayout() );
label = new JLabel(icon);
c.add(label);
setSize(800,600);
setVisible(true);
}
public static void main (String args[]) {
Test t = new Test(); t.setDefaultCloseOperationJFrame.EXIT_ON_CLOSE);
}
NOTE: the image is in the same directory of the java and class files.
This code should just show my picture, right?? then what might be wrong ??