[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Canvas and Panel

Posted on 2002-06-30
3
Medium Priority
?
290 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 400 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

650 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