Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Java - Flickering (fast help needed)
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
xHoly-Divinity




PostPosted: Tue Jan 17, 2006 5:06 pm   Post subject: Java - Flickering (fast help needed)

code:

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

public class BouncePicApplet extends Applet implements Runnable
{

    int x, y;
    int dx, dy;
    int appletWidth, appletHeight;

    public void run ()
    {
        while (true)
        {
            try
            {
                Thread.sleep (50);
            }
            catch (InterruptedException e)
            {
            }
            if ((x + dx < 0) || (x + 100 > appletWidth))
            {
                dx = -dx;
            }
            if ((y + dy < 0) || (y + 100 > appletHeight))
            {
                dy = -dy;
            }
            x += dx;
            y += dy;
            repaint ();
        }
    }


    public void init ()
    {
        x = 0;
        y = 0;
        dx = 3;
        dy = 3;

        appletWidth = getSize ().width;
        appletHeight = getSize ().height;

        Thread t = new Thread (this);
        t.start ();
    }


    public void paint (Graphics g)
    {
        g.fillOval (x, y, 100, 100);
    }
}


I know that the circle does not appear to flicker, however, if u have a full screen applet with lots of large picture it flickers like crazy, it also depends on the computer. How to fix this problem, if anyone could fill in the code... that would be much appreciated Smile
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Wed Jan 18, 2006 1:11 am   Post subject: (No subject)

double buffering helps.. seach this forum.. you'll find your solution
xHoly-Divinity




PostPosted: Wed Jan 18, 2006 4:49 pm   Post subject: (No subject)

Couldn't find it.... can u just start me off....
wtd




PostPosted: Wed Jan 18, 2006 4:54 pm   Post subject: (No subject)

Google for "double buffering" and restrict your search to java.sun.com.

Learning how to search effectively is more important than the answer in this case.
xHoly-Divinity




PostPosted: Wed Jan 18, 2006 5:23 pm   Post subject: (No subject)

http://java.sun.com/developer/J2METechTips/2001/tt0725.html

That's the site i managed to find.... didn't help much though :S
wtd




PostPosted: Wed Jan 18, 2006 5:34 pm   Post subject: (No subject)

Because that's for use with cellphones and PDAs.
xHoly-Divinity




PostPosted: Wed Jan 18, 2006 5:44 pm   Post subject: (No subject)

Common dude.... can u just help me out
wtd




PostPosted: Wed Jan 18, 2006 5:59 pm   Post subject: (No subject)

We are helping you.

What we will not do is simply hand you the answer on a silver platter.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: