I have read this thread:

http://forums.java.net/jive/thread.jspa?threadID=45350&tstart=0

and it's very close to the subject matter I am currently researching. But I 
wanted to ask a higher level question.

I thought all Swing components had a UI delegate that drew the component using 
Java2D calls. I have traced the paint() code in Component and JComponent, and 
they look like they are passing around the same Graphics object on which 
paint() was originally called. The only modification seems to be if Debug 
Graphics are being used, it substitutes one of those for the Graphics object.

So why is it if I override paint() in my container subclass (say a JPanel 
subclass), and then scale the Graphics object, then call super.paint(), why is 
it that Swing doesn't seem to work the way I would expect it to? I.e., when 
drawing, it's not really "doing the right thing" with the scaled Graphics 
instance it is passed.

As the other thread pointed out, if I add JComponents to my JPanel subclass, 
when they first appear they are indeed drawn at the scaled size. But then, 
moving the mouse over the JPanel, or triggering a repaint, causes the Swing 
component to be drawn again in its original, non-scaled size, while I also 
still have pixels on screen that represent the scaled JComponents but are just 
a drawing - I cannot interact with them via the mouse or keyboard.

What is Swing doing that makes this simple scaling call not work? And what is 
the secret ingredient that makes something like JXTransformer work correctly? 
(Nearly correctly anyway, I'm still seeing an issue on Mac OS X with the 
TextJXTransFormer demo (from the above link) where the border of the focused 
JButton isn't drawn completely around the button, the right-side of the border 
is not being painted.)

Rob
[Message sent by forum member 'robross' (robross)]

http://forums.java.net/jive/thread.jspa?messageID=293452

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to