الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

الصوره تعمل Flikering ابيض

مغلق
بدأه NUCLEAR في 7 مارس 2006 · 4 رد · 666 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

استخدم هذا ال 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++;
}}

هنا تظهر المساحة البيضاء عند تغير الصورة لماااااااااااااااااااااااااااااذاااااااااااا؟

تم تعديل هذه المشاركة بواسطة NUCLEAR في 7 مارس 2006 في 02:40

Moore’s Law

– “Number of transistors in chips doubles every 18 
months”.
–  Every 10 years, processors are 100 times more 
powerful.

Gilder’s Law

– “Bandwidth grows at least three times faster than 
computer power”.
– Assuming bandwidth doubles every 12 months; 
every 10 years, it is 1000 times better.
#2
public void run()
{
while (true){
try
{
Rect=null;
Rect=ImageIO.read(in);
if(Rect==null)
{}
else
{
SwingUtilities.invokeLater(new Runnable(){
public void run(){
I.update(Rect);
}
});
System.out.println(Sign+" Frame NO"+":"+c);
c++;
}}
#3

ياريت تفهمنى ايه الفرق؟؟

Moore’s Law

– “Number of transistors in chips doubles every 18 
months”.
–  Every 10 years, processors are 100 times more 
powerful.

Gilder’s Law

– “Bandwidth grows at least three times faster than 
computer power”.
– Assuming bandwidth doubles every 12 months; 
every 10 years, it is 1000 times better.
#4

http://java.sun.com/j2se/1.4.2/docs/api/ja...gUtilities.html

http://java.sun.com/j2se/1.4.2/docs/api/ja....lang.Runnable)

إذا أردت أن تعدل أي شيء في Swing (ظاهر في الشاشة) سواء كان تغيير لون أو شكل أو موقع أو أي تحديث، يجب أن يتم التحديث في خيط AWT Thread أو الخيط المسؤول عن رسم النافذة..

مثالك في الأعلى، يحدث Swing في خيط أنت صنعته ولا يتم التحديث في AWT Thread،، ولهذا لا يتم التحديث بصورة طبيعية.

ماذا نفعل إذا حدث شيء في خيط آخر ونريد أن نحدث Swing من خلاله؟

نجعل التحديث في AWT Thread الخاص بالرسم.. ولذلك عندنا وسيلة في SwingUtilities نعطيها Runnable وتقوم هذه الأداء بمناداة هذا Runnable الذي صنعناه في داخل AWT Thread، ... ..

لاحظ اسمه invokeLater يعني نفذ هذا الأمر متى ما وجدت نفسك فارغا من أية أعمال أخرى!

ملاحظة: تستطيع أيضا أن تستخدم invokeAndWait وهذه سوف توقف Thread الحالي، حتى ينفذ Runnable الذي تريد عمله.

في الغالب، استخدم invokeLater.

آمل أن يكون الشرح واضحا.

بالتوفيق!

#5

شكرا شكرا شكرا

شكرا شكرا شكرا

شكرا شكرا شكرا

Moore’s Law

– “Number of transistors in chips doubles every 18 
months”.
–  Every 10 years, processors are 100 times more 
powerful.

Gilder’s Law

– “Bandwidth grows at least three times faster than 
computer power”.
– Assuming bandwidth doubles every 12 months; 
every 10 years, it is 1000 times better.

هذا الموضوع مغلق.

مواضيع مشابهة