import javax.swing.*;
import java.awt.*;
public class Images extends JApplet implements Runnable
{
JPanel jp;
JLabel l1;
String []s={"1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg"};
int i=0;
Thread t1;
public void init()
{
jp=new JPanel();
getContentPane().add(jp);
l1=new JLabel("");
jp.add(l1);
t1=new Thread(this);
t1.start();
}
public void run()
{
try
{
while(true)
{
Icon ic=new ImageIcon(s[i++]);
l1.setIcon(ic);
if(i>=s.length)
i=0;
Thread.sleep(1000);
}
}
catch(Exception e)
{}
}
}
/**
import java.awt.*;
public class Images extends JApplet implements Runnable
{
JPanel jp;
JLabel l1;
String []s={"1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg"};
int i=0;
Thread t1;
public void init()
{
jp=new JPanel();
getContentPane().add(jp);
l1=new JLabel("");
jp.add(l1);
t1=new Thread(this);
t1.start();
}
public void run()
{
try
{
while(true)
{
Icon ic=new ImageIcon(s[i++]);
l1.setIcon(ic);
if(i>=s.length)
i=0;
Thread.sleep(1000);
}
}
catch(Exception e)
{}
}
}
/**
No comments:
Post a Comment