![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
You know everytime you call repaint() the program redraws everything, correct? And you know how that makes your program "blink?" Is it possible to get rid of the accursed blinking?
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Sep 2004
Location: South Africa, Eastern Cape
Posts: 28
Rep Power: 0
![]() |
Use a buffer. That will help alot.
Image buffer;
Graphics gd;
public void update(graphics g)
{
paint(g);
}
public void paint(graphics g)
{
*if (buffer == null)
*{
* *buffer = createImage(getWidth(), getHeight());
* *gd = buffer.getGraphics();
*}
*if (buffer.getWidth(null) != getWidth() || buffer.getHeight(null) != getHeight())
*{
* *buffer = createImage(getWidht(), getHeight());
* *gd = buffer.getGraphics();
*}
*// Reset background if need to
*gd.setColor(Color.WHITE);
*gd.fillRect(0,0, getWidth(), getHeight());
*// Do all your drawing here
*g.drawImage(buffer, 0, 0, null);
}Well I am assuming u are using a canvas or something cos that is the only place I encountered flickering. Hopefully this will help.
__________________
Be vewwy vewwy quiet. I'm hunting wuntime ewwors. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|