اخواني عملت برنامج لاظهار صور بشكل متتالي و لكن انا لا اجيد استخدام الthread. عندما اعمل للبرنامج كومبالير لا يظهر اي خطاء و لكن رغم ذلك لم تظهر الصور!!! الجو المساعده في معرفه الخطاء و هذا هو البرنامج
import java.awt.event.*;
import java.awt.*;
import java.applet.*;
public class Mohamed1 extends Applet implements Runnable {
Image q1 = getImage(getDocumentBase(),"ashraf1.jpg");
Image q2 = getImage(getDocumentBase(),"ashraf2.jpg");
Image q3 = getImage(getDocumentBase(),"ashraf3.jpg");
Image q4 = getImage(getDocumentBase(),"ashraf4.jpg");
Image[] zz={q1,q2,q3,q4};
Button a= new Button("start");
Button b = new Button("stop");
int n = 0;
Thread sora;
public void init() {
setBackground(Color.blue);
add(B);
add(a);
a.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
sora.start();
}
});
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
sora.stop();
}
});
sora = new Thread(this);
sora.start();
}
public void paint(Graphics g){
if (n<3){ g.drawImage(zz[n],0,0,this);
n++;}
else {g.drawImage(zz[n],0,0,this);
n=0;}
}
public void run(){
while (true){
repaint();
try{ sora.sleep(2000);}
catch(InterruptedException e){}
}
}
}
