Author |
Message |
xHoly-Divinity
|
Posted: 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 Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
rizzix
|
Posted: Wed Jan 18, 2006 1:11 am Post subject: (No subject) |
|
|
double buffering helps.. seach this forum.. you'll find your solution |
|
|
|
|
![](images/spacer.gif) |
xHoly-Divinity
|
Posted: Wed Jan 18, 2006 4:49 pm Post subject: (No subject) |
|
|
Couldn't find it.... can u just start me off.... |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
xHoly-Divinity
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Wed Jan 18, 2006 5:34 pm Post subject: (No subject) |
|
|
Because that's for use with cellphones and PDAs. |
|
|
|
|
![](images/spacer.gif) |
xHoly-Divinity
|
Posted: Wed Jan 18, 2006 5:44 pm Post subject: (No subject) |
|
|
Common dude.... can u just help me out |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|