Skip to main content

how to add invalid rectangles to redraw area

1 reply [Last post]
Joined: 2010-03-22

I am processing a paintComponent(Graphics g) event. Sometimes, I may have a thread running and I want to make the area on the screen that is invalid larger than the clip area that the graphics object passed in indicates it is. I've tried getting the clipbounds 'g' using g.getClip, g.getClipBounds etc. and using my additional info to try to increase the clip bounds to a larger rectangle. This won't work. I dont' want to call repaint and do the entire panel again.

Is there a way to change the area of the panel that is invalid?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-07-17

Hi Brian,

Why don't you use the JComponent method
public void repaint(long tm,
int x,
int y,
int width,
int height)

The reason that you cannot enlarge the clip might be under some circumstances that internally the clipping area was constrained to some maximum value. When the clipping is constrained, it cannot be set to a larger area.