Skip to main content

Canvas vs. JComponent for drawing (again)

1 reply [Last post]
Anonymous

[I sent this the first day I signed up for this list, so I'm thinking a snafu
might have kept it from posting, or AOL might have blocked any replies at
first, anyways here it is:]

I'm reasonably proficient in Swing but as I've began programming in java2D,
I'm puzzled by all the usages of java.awt.Canvas I've seen as the GUI component
in which the custom graphics are drawn in. So far, I've used JComponent
subclasses for this purpose. Is there a reason I should use Canvas instead? I
presume it is heavyweight, whereas JComponent is lightweight, which I thought
was the preferred way of implementing GUI and graphics in java.

thanks in advance,
jhst463@aol.com

P.S. Do me a big favor and even if you don't have an answer, just reply
anyway to confirm that this message got thru. thanks again.

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Reply viewing options

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

Hi Jonathan,

yes, in Swing applications JComponent should be used, and not
Canvas. Canvas is a heavyweight component and using it may interfere
with Swing's repainting.

Thanks,
Dmitri

On Fri, May 26, 2006 at 12:28:57AM -0400, Jonathan Mast wrote:
> [I sent this the first day I signed up for this list, so I'm thinking a snafu
> might have kept it from posting, or AOL might have blocked any replies at
> first, anyways here it is:]
>
> I'm reasonably proficient in Swing but as I've began programming in java2D,
> I'm puzzled by all the usages of java.awt.Canvas I've seen as the GUI component
> in which the custom graphics are drawn in. So far, I've used JComponent
> subclasses for this purpose. Is there a reason I should use Canvas instead? I
> presume it is heavyweight, whereas JComponent is lightweight, which I thought
> was the preferred way of implementing GUI and graphics in java.
>
>
> thanks in advance,
> jhst463@aol.com
>
>
> P.S. Do me a big favor and even if you don't have an answer, just reply
> anyway to confirm that this message got thru. thanks again.
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".