Wondering about setPaintingIsUnclipped()


I’m using setPaintingIsUnclipped(), and I am definitely drawing within my bounds, but what I am seeing is that if a parent component has setPaintingIsUnclipped(true), it is possible for child components to draw outside the parent’s bounds.

For example, I have a button in the corner of its parent Component with bounds = (-2, 0, 32, 16). The reason I put it at x coordinate -2 is so that its frame will not be visible. The both Component have setPaintingIsUnclipped(true), I am only drawing within the bounds, but the child is not getting clipped to the parent’s bounds.

So I guess what I am asking, is it expected behavior that when setPaintingIsUnclipped is true, child Components can draw outside their parent’s bounds?


I knew I should never have made that method public. No, it won’t clip it’s children.

Why are you using it anyway? My advice is to leave it alone.


It seems to be working with the exception of this one button. My window is a little bit slow to resize and scroll things and it needs all the help it can get. I’m making a lot of use of partially transparent stroked paths, transparent shading, gradient fills, etc…


Well, good luck with it, though it seems unlikely that it’d be any help unless you have a really huge number of unclipped components inside the same parent. I wrote it for Drawables where there might be hundreds of DrawablePath objects making up an image - it certainly wasn’t designed for anything more complex than a simple drawable.