Ericyue
04-13-2012, 03:46 AM
hi ,
i am doing a program which will display the image and update after x seconds. i have set the image name to be 1.jpeg , 2.jpeg .. till 100.jpeg. below is the code i have done so far
import java.util.*;
import java.awt.*;
import java.io.*;
import javax.swing.*;
public class Tester extends JWindow
{
public static void main(String[]args)
{
int i = 1;
ImageIcon ii=new ImageIcon(i + ".jpeg");
JLabel label=new JLabel(ii);
JFrame frame=new JFrame("Show Image");
frame.add(label);
while(i<6)
{
i++;
label.setIcon(new ImageIcon( i + "jpeg"));
}
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,400);
frame.setVisible(true);
}
}
it can compile without error but when i run it, it only show the frame with empty gray background. can anyone tell me how to settle this problem.
thanks in advance for helping me .. thanks a lot .
i am doing a program which will display the image and update after x seconds. i have set the image name to be 1.jpeg , 2.jpeg .. till 100.jpeg. below is the code i have done so far
import java.util.*;
import java.awt.*;
import java.io.*;
import javax.swing.*;
public class Tester extends JWindow
{
public static void main(String[]args)
{
int i = 1;
ImageIcon ii=new ImageIcon(i + ".jpeg");
JLabel label=new JLabel(ii);
JFrame frame=new JFrame("Show Image");
frame.add(label);
while(i<6)
{
i++;
label.setIcon(new ImageIcon( i + "jpeg"));
}
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,400);
frame.setVisible(true);
}
}
it can compile without error but when i run it, it only show the frame with empty gray background. can anyone tell me how to settle this problem.
thanks in advance for helping me .. thanks a lot .