Jump to content

  • Log In with Google      Sign In   
  • Create Account


java applet flickering


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 lride   Members   -  Reputation: 633

Like
0Likes
Like

Posted 12 June 2013 - 11:20 AM

import java.applet.*;
import java.awt.*;

public class Game extends Applet implements Runnable
{
	Thread th;
	public void start()
	{
		th=new Thread(this);
		th.start();
	}
	public void run()
	{
		while(true)
		{
			try{
				repaint();
				th.sleep(0);
			}catch(Exception e)
			{
				e.printStackTrace();
			}
		}
	}
	public void paint(Graphics g)
	{
		Dimension d=getSize();
		g.fillRect(0, 0, d.width, d.height);
		g.setColor(Color.green);
		g.drawLine(0,  0,  100,  100);
	}
}

The applet flickers a lot so it's very disturbing.

Is there something I'm doing wrong?


An invisible text.

Sponsor:

#2 Zaoshi Kaba   Crossbones+   -  Reputation: 3608

Like
3Likes
Like

Posted 12 June 2013 - 01:01 PM

No, it's right. Google double buffering, it'll fix your issue.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS