Question

What are the differences between using a Canvas control or a Label control for drawing an image?

Both controls seem to have similar capabilities in terms of drawing images onto their displayable area, and can both use PaintListeners to further customize the act. I have always assumed that Canvases are more suited for the purpose than labels simply due to their name, but I cannot determine the actual practical differences. In what scenarios would you use one over the other for loading an image file and painting the image onto the control?

Was it helpful?

Solution

The Label inherits its drawing capabilities from Control, as well as many of the features in Canvas. But Canvas was built with extra controls for images, like dynamic drawing, buffering and partial update.

Summing up, it is ok to use labels for static small images, but when it comes to heavy-duty use, a canvas is more appropriate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top