Well, java.awt.Canvas is a legacy AWT class, while JComponent is Swing.
 Thus Canvas does not support the numerous things that every Swing
component does.  (e.g., paintComponent(), etc.)

Anyway, in practice, unless you were writing a purely AWT GUI for some
reason (e.g., needed to write an applet that had to run in a 1.1 JVM or
something) there's no real reason for you to use Canvas, as it's all but
deprecated given the advent of Swing.  (It's not officially deprecated
or removed because 1) to maintain backwards compatibility, and 2)
because Swing is built on top of at least the core of AWT and so would
break if AWT was ditched.)

HTH,

DR

Jonathan Mast wrote:
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,
[EMAIL PROTECTED]

===========================================================================
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