<AWT Dev> Paint a JComponent without clipping children

Anthony Petrov anthony.petrov at oracle.com
Thu May 5 11:46:27 PDT 2011


Hi Herve,

JComponent is a Swing component. I suggest you to subscribe to the 
swing-dev at openjdk.java.net mailing list and post your question there.

--
best regards,
Anthony

On 5/5/2011 2:14 AM, Herve Girod wrote:
> Hello,
> 
> I'm new to this mailing list and I'm not *really* asking how to do it 
> because I know how it's possible to do it by using a hack (mainly 
> getting and setting the BUFFER and TILE parts of the "flags" field for 
> the JComponent by reflection, and "rewriting" the paintChildren method 
> without the clipping part). I'm using it in 
> the http://sourceforge.net/projects/j661/  project to be able to use 
> custom Swing containers which only offset the position or transform 
> their children graphic context, without clipping them (allowing to use 
> negative positions for the children widgets, for example).
> 
> I'm asking if there is a way to do this without playing with the private 
> "flags" field, because I need to be able to do the same thing in a 
> restricted JNLP environment. I know a "regular"' way to do this, but it 
> would be a little cumbersome (offsetting the positions of all children 
> widgets in the parent container, to be sure that the positions of the 
> children are never negative, for example). But it's not very good for 
> performance when something change in the parent container....
> 
> There are many projects which either play with this private field, or 
> use transforms, but in this later case they still apply a clipping. Is 
> it possible to play with the Graphics2D clippings for example before 
> using the JComponent paintChildren method - or would this approach work 
> ?  Or would the only way to do it without compromising Security be to 
> have a way to get / set the TILE and BUFFER value of the "flags" field 
> without reflection ?
> 
> Thanks by advance if you have ideas about this, and sorry if this prose 
> is not crystal clear ;)
> 
> Herve Girod
> 
> 



More information about the awt-dev mailing list