Solved

Canvas and Panel

Posted on 2002-06-30
3
288 Views
Last Modified: 2012-05-04
Since you can use the Graphics methods on a Panel, what is the advantage of using a Canvas instead of a Panel to display an image, for example?
0
Comment
Question by:HanRui
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Expert Comment

by:Ovi
ID: 7121081
Panel is a container, canvas is a component. Of course both of them have as superclass Component, but they coming from different class tree paths(roots). On a Panel you can add components which meens that you can overlap what are you doing in the paint method; this can be a good think, or a bad one, depending on your application type/design. Canvas on the other hand is "specialized" for graphic operations. Basically there is no difference from the paint method point of view. All is very depending of your application specifications and needs.
0
 

Author Comment

by:HanRui
ID: 7121511
Thanks, but this still this doesn't explain to me the need for a Canvas class since Panel can do everything that Canvas can do.
0
 
LVL 2

Accepted Solution

by:
allie earned 100 total points
ID: 7122218
The advantage of using a Canvas for graphics (as opposed to a Panel), is that Canvas allows more flexible graphics programming.  For example, you can set a GraphicsConfiguration when creating a Canvas (whereas in a Panel you could set the Layout).  Canvas allows you to use more advanced graphics, utilize more periphery interaction (like with printers, moniters, and mulit-screen environments), and have better (optimal) trapping of input events from the user related to graphics.  (Like letting the user draw lines in the graphics area.)  I've never even tried to let a user draw using the mouse on a Panel (for instance), and if you can even do it I'm sure you'd need some extra code to handle it that would be unnecessary in Canvas.

allie
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question