Skip to main content

Prevent Painting

3 replies [Last post]
Anonymous

Hi,

I am extending JDesktopPane and doing some custom work there like setting the new bounds to all the JInternalFrames present in the desktop pane. During that I don't want any repaints to happen on the desktop pane (setting bounds will paint internal frames and desktop pane). After I perform the entire operation I want to paint the desktop pane. So my question is how to disable the painting on desktop pane (and all its children) during that opeartion and how to enable after completing that operation.

Thanks,
Jana

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Scott Violet

On Tue, Sep 23, 2003 at 08:31:20AM -0400, swing-feedback@javadesktop.org wrote:
> Hi,
>
> I am extending JDesktopPane and doing some custom work there like
> setting the new bounds to all the JInternalFrames present in the
> desktop pane. During that I don't want any repaints to happen on the
> desktop pane (setting bounds will paint internal frames and desktop
> pane). After I perform the entire operation I want to paint the
> desktop pane. So my question is how to disable the painting on
> desktop pane (and all its children) during that opeartion and how to
> enable after completing that operation.

As Shannon mentioned repaints aren't processed immediately.
None-the-less if you truly want to disable repaints for certain
widgets you could override repaint to do nothing, but this is hard as
there may be quite a few widgets to cover. Another approach is to
create your own RepaintManager that overrides addDirtyRegion and does
not call super for certain widgets. Be aware that if a widget higher
in the containment hierarchy triggers a repaint your desktop pane will
be painted. Similarly if the window is exposed the system will
generate a paint event that will include the desktop pane.

-Scott

shan-man
Offline
Joined: 2006-02-17

Hi Jana,

> Hi,
>
> I am extending JDesktopPane and doing some custom
> work there like setting the new bounds to all the
> JInternalFrames present in the desktop pane. During
> that I don't want any repaints to happen on the
> desktop pane (setting bounds will paint internal
> frames and desktop pane). After I perform the entire
> operation I want to paint the desktop pane. So my
> question is how to disable the painting on desktop
> pane (and all its children) during that opeartion and
> how to enable after completing that operation.
>
> Thanks,
> Jana

To be honest, I'm not sure you really need to do anything here. It may be true that the operations which you're performing cause repaint() to be invoked on various parts of your GUI. But the paint operations will not occur until you have finished what you're doing (as long as you're performing these operations on the event-dispatch thread).

Each repaint request will simply union the requested area with any other areas pending painting. Once you're done, the area encompassing all of these areas will be painted.

Does this help?
Shannon

zander
Offline
Joined: 2003-06-13

Maybe a stupid answer is to put the operation in the AWTEvent thread..

Something like calling this from paint() when a certain condition is true.