Thread View: borland.public.jbuilder.java.swing
4 messages
4 total messages
Started by Bill Darbie
Wed, 19 Nov 2003 01:42
How do I get the paint Rectangle in paintComponent()
Author: Bill Darbie
Date: Wed, 19 Nov 2003 01:42
Date: Wed, 19 Nov 2003 01:42
23 lines
1898 bytes
1898 bytes
Help! I have been stuck on this problem for hours. How do I get the Rectangle of the original repaint() call in a components paintComponent(Graphics graphics) method? For example. Say a repaint(0, 0, 10, 10) is called somewhere in the code. Say my JComponent has a bounds of Rectangle(9, 9, 5, 5) In the components paintComponent(Graphics graphics) method I can call: graphics.getClipBounds() and that will return (0, 0, 1, 1) Basically it returns the intersection of the original repaint rectangle (0, 0, 10, 10) and my bounds (9, 9, 5, 5) relative to my components coordinates, which gives 0, 0, 1 1. But I want a way to get the 0,0,10,10 rectangle from the paintComponent method. Is there a way to do this? Thanks, Bill
Re: How do I get the paint Rectangle in paintComponent()
Author: John McGrath [TeamB]
Date: Wed, 19 Nov 2003 06:55
Date: Wed, 19 Nov 2003 06:55
21 lines
1663 bytes
1663 bytes
On 11/18/2003 at 8:42:38 PM, Bill Darbie wrote:
> Help! I have been stuck on this problem for hours.
>
> How do I get the Rectangle of the original repaint() call
> in a components paintComponent(Graphics graphics) method?
You can't. There is no guaranteed correspondence between repaint()
calls and paintComponent() calls. Each repaint() call could result in
zero, one, or many paintComponent() calls. And each paintComponent()
call could be the result of one or many repaint calls, or it could be
the result of some event other than a repaint call.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Re: How do I get the paint Rectangle in paintComponent()
Author: Bill Darbie
Date: Wed, 19 Nov 2003 14:56
Date: Wed, 19 Nov 2003 14:56
32 lines
2394 bytes
2394 bytes
"John McGrath [TeamB]" <ng-b@JPMcGrath.net> wrote in message news:3fbb2203@newsgroups.borland.com... > On 11/18/2003 at 8:42:38 PM, Bill Darbie wrote: > > > Help! I have been stuck on this problem for hours. > > > > How do I get the Rectangle of the original repaint() call > > in a components paintComponent(Graphics graphics) method? > > You can't. There is no guaranteed correspondence between repaint() > calls and paintComponent() calls. Each repaint() call could result in > zero, one, or many paintComponent() calls. And each paintComponent() > call could be the result of one or many repaint calls, or it could be > the result of some event other than a repaint call. But once the paintComponent() is called, there is a Rectangle describing the area to be repainted that indirectly caused the call to happen. Is there no way to get that Rectangle? Thanks, Bill > > -- > Regards, > > John McGrath [TeamB] > > --------------------------------------------------- > Before sending me e-mail, please read: > http://www.JPMcGrath.net/newsgroups/e-mail.html
Re: How do I get the paint Rectangle in paintComponent()
Author: John McGrath [TeamB]
Date: Thu, 20 Nov 2003 04:23
Date: Thu, 20 Nov 2003 04:23
42 lines
2678 bytes
2678 bytes
On 11/19/2003 at 9:56:00 AM, Bill Darbie wrote:
> But once the paintComponent() is called, there is a Rectangle
> describing the area to be repainted that indirectly caused the call
> to happen. Is there no way to get that Rectangle?
I am not really sure what you mean by the phrase "that indirectly
caused the call to happen". If you drop it, you get "there is a
Rectangle
describing the area to be repainted", which is precisely correct.
That is all the information that is provided, all that is available,
and all that really makes sense in all contexts that the
paintComponent() method may be called.
The paintComponent() method is called by the painting subsystem when it
wants the component to paint itself. The paintComponent() method
simply provides the service to the painting system. It is not supposed
to know the context in which it is being called.
It does not know why it was called. It is possible that the repaint()
method was called, but it could also be that the Window containing the
component has just been exposed do to another window closing or being
moved.
It does not know what it is painting on, just that it is a Graphics
context. The Graphics could refer to the screen, or to a buffered
image used for screen double buffering, or to a buffer that will be
used to print an image of the component, or to a buffer that will be
used to generate a PDF file.
Its job is to paint itself on the given graphics context. That is
exactly what it should do, no more and no less.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads