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 / General / November 2005

Tip: Looking for answers? Try searching our database.

paint in canvas

Thread view: 
tratrillo@yahoo.it - 02 Nov 2005 11:52 GMT
sorry for the probably dumb question,
but I'm new to java: I have a small example
that draws a rect in a paint method of
the canvas.

based on an event I redraw the rect with a
different color (with a call to fillRect).

The problem is that if I put the window in
background and then get it in forground, I
see the change, otherwise nothing appens!
Seem I'm missing a update call.

By the way, if I call the sequence
canvas.setVisible(false);
canvas.setVisible(true);
it works, but I do not want to redraw all the
canvas, just the rect, to avoid flickering.

thanks
G.
Roedy Green - 02 Nov 2005 11:56 GMT
>it works, but I do not want to redraw all the
>canvas, just the rect, to avoid flickering.

I don't see how anyone will be able diagnose problems without seeing
the  code.

to repaint just a small part of the drawing, use a repaint with a
clipregion.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Thomas Hawtin - 02 Nov 2005 12:10 GMT
> The problem is that if I put the window in
> background and then get it in forground, I
> see the change, otherwise nothing appens!
> Seem I'm missing a update call.

And if you drag a window over the top, only the are that has been
covered is redrawn?

> By the way, if I call the sequence
> canvas.setVisible(false);
> canvas.setVisible(true);
> it works, but I do not want to redraw all the
> canvas, just the rect, to avoid flickering.

You need to tell the UI toolkit that the rectangle is 'damaged'. Call
Component.repaint with the bounds of the rectangle in the component's
coordinates.

http://download.java.net/jdk6/docs/api/java/awt/Component.html#repaint(int,
int, int, int)

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

tratrillo@yahoo.it - 02 Nov 2005 14:29 GMT
thank you very much: it was the missing repaint!

G.
Giorgio Schiavon - 02 Nov 2005 16:14 GMT
Hi,
I'm here again: the repaint works correctly
using jdk, but using kaffe, what I get is...
only the repaint og the modified rectangle :-(
That is the window is cleared, and then,
only the rect indicated in repaint is repainted.

Any idea why kaffe clear all the windows?

thanks
G.
Roedy Green - 03 Nov 2005 08:18 GMT
>Any idea why kaffe clear all the windows?

For a list of the usual mistakes see
http://mindprod.com/jgloss/paint.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



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



©2009 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.