aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Difference between Panel and Canvas Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Difference between Panel and Canvas" Watch "Difference between Panel and Canvas" New topic
Author

Difference between Panel and Canvas

Pankaj Halder
Greenhorn

Joined: Sep 10, 2008
Posts: 25
When should they be used, respectively? They seem very similar to me.
Pavan Kumar Srinivasan
Greenhorn

Joined: Sep 17, 2008
Posts: 27
w.r.t Swing there is no such thing as Canvas...a JPanel is analogous to a Canvas in general.

Please be more specific about the toolkit Swing/Swt being used.
Pankaj Halder
Greenhorn

Joined: Sep 10, 2008
Posts: 25
Sorry. I meant AWT.
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Originally posted by Pankaj Halder:
When should they be used, respectively? They seem very similar to me.


java.awt.Panel implements the Container interface, java.awt.Canvas does not but it does clear the background before painting itself.

It used to be (more than a decade ago, before the release of JDK 1.1) that to create a completely new Component one had to extend either Canvas or Panel, both heavyweight classes. Starting with JDK1.1 it was possible to extend java.awt.Component (or java.awt.Container) directly. Since then there hasn't been much use for Canvas.


bitguru blog
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Originally posted by Pankaj Halder:
Sorry. I meant AWT.


But why AWT and not the more robust Swing?
 
 
subject: Difference between Panel and Canvas