Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2004

Tip: Looking for answers? Try searching our database.

Own component flashes - despite double buffering

Thread view: 
A. Farber - 15 Feb 2004 14:52 GMT
Hi,

I have a small applet + source code at

   http://pref.dyndns.org/flash/

where I'm trying to implement a card game.
All cards are painted in my own Component
(called "board"). I use double buffering
(please see offImage and offGraph in the
http://pref.dyndns.org/flash/Board.java )
and still that component flashes horribly
on every repaint().

It wasn't like that in the previous version
of the applet, where I was just drawing on
the applet's Graphics - without a separate
component for the cards.

What is happening there? Is the layout manager
maybe trying to re-layout the whole applet?
Do I somehow have to block PAINT_EVENT's or
some other events? Thank you for any hints

Regards
Alex
ak - 15 Feb 2004 16:28 GMT
> where I'm trying to implement a card game.
> All cards are painted in my own Component
[quoted text clipped - 3 lines]
> and still that component flashes horribly
> on every repaint().

add this to your code:

public void update(Graphics g) {
   paint(g);
}

see also here for example on double buffering:
http://groups.google.de/groups?hl=de&lr=&ie=UTF-8&oe=UTF-8&selm=buq026%24um5
%241%40online.de

____________

http://reader.imagero.com the best java image reader.
Knute Johnson - 15 Feb 2004 20:21 GMT
>>where I'm trying to implement a card game.
>>All cards are painted in my own Component
[quoted text clipped - 17 lines]
>
> http://reader.imagero.com the best java image reader.

A.

You didn't look carefully at my Pong applet or you would have seen the
exact code above.  What ak didn't tell you is that update() clears the
component and calls paint().  When you override it with just a call to
paint(), no flicker.

Signature

Knute Johnson
email s/nospam/knute/
Molon labe...

A. Farber - 16 Feb 2004 10:23 GMT
> >>where I'm trying to implement a card game.
> >>All cards are painted in my own Component
[quoted text clipped - 9 lines]
> >     paint(g);
> > }

> You didn't look carefully at my Pong applet or you would have seen the
> exact code above.  What ak didn't tell you is that update() clears the
> component and calls paint().  When you override it with just a call to
> paint(), no flicker.

Hi, sorry but that's you who didn't look at the code ;-)
I have the update() function there. I think the flickering
is somehow related to the fact that my own component
extends Component. I've changed it to extend Canvas and
the flashing is gone now:

http://pref.dyndns.org/grid2/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.