استخدم هذا ال Class لعرض Splash Screen
public class Splash extends JWindow{
protected JLabel frame;
public ImageIcon image;
public int X;
public int Y;
public Splash(Image image,int X,int Y){
this.image=new ImageIcon(image);
JFrame SFrame=new JFrame("Splash");
JWindow SWindow=new JWindow(SFrame);
this.frame=new JLabel(this.image);
this.getContentPane().add(this.frame,0);
this.pack();
this.setLocation(X,Y);
this.setVisible(true);
}
public Splash(int X,int Y,Rectangle R){
JFrame SFrame=new JFrame("Splash");
JWindow SWindow=new JWindow(SFrame);
this.frame=new JLabel(this.image);
this.getContentPane().add(this.frame,0);
this.pack();
this.setBounds®;
this.setVisible(true);
}
public void update(Image image){
this.image=new ImageIcon(image);
this.frame=new JLabel(this.image);
this.getContentPane().add(this.frame,0);
pack();
}
}لا مشكله فى عمل البرنامج من هنا وتتغير الصورة وكأنك تتفرج على صوره GIF
ولا ترعش او تظهر مساحة بيضاء
public class TEST{
public static void main(String ARGS[]){
try{
File F=new File("0.PNG");
Image G=ImageIO.read(F);
System.out.println("0");
Splash U=new Splash(G,0,0);
System.out.println("1");
System.out.println("2");
for (int cc=0;cc<5;cc++){
File F1=new File(cc+".PNG");
Image G1=ImageIO.read(F1);
System.out.println(cc);
U.update(G1);
F1=null;
G1=null;
System.out.println("END");
}}
catch(Exception e){
System.out.println(String.valueOf(e));}
}}ولكن ....
public class Threaded extends Thread
{
........
public void run()
{
while (true){
try
{
Rect=null;
Rect=ImageIO.read(in);
if(Rect==null)
{}
else
{
I.update(Rect);
System.out.println(Sign+" Frame NO"+":"+c);
c++;
}}هنا تظهر المساحة البيضاء عند تغير الصورة لماااااااااااااااااااااااااااااذاااااااااااا؟