Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

use a Canvas or JPanel?

843789Aug 3 2010 — edited Aug 4 2010
I am not asking about the basic differences between a Canvas and a JPanel. Rather, based on the following criteria, which is the better choice:

(-) I will be "doodling": just drawing strokes in a Component.
(-) The strokes will be drawn slowly and asynchronously, (so I will have to deal with threading).
(-) I have no need for 3-d imaging.
(-) I don't need to respond to user events.
(-) That JPanel is also a container should have no benefit. I am just drawing shapes.

The decision about whether to use a heavy-weight (Canvas) vs. a light-weight (JPanel) would seem to have important implications?

As of now, I'd choose the Canvas because the Graphics, Graphics2D, Canvas are all in the same package. And Canvas seems explicitly designed to support drawing, and only drawing. Though, using a light-weight component might be the better choice. Isn't that why Swing was developed? Before proceeding, I'd just like to choose the better Component. Any advice welcome.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 1 2010
Added on Aug 3 2010
5 comments
2,221 views