• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Panel and Canvas

 
Pankaj Halder
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When should they be used, respectively? They seem very similar to me.
 
Pavan Kumar Srinivasan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry. I meant AWT.
 
Brian Cole
Author
Ranch Hand
Posts: 907
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pankaj Halder:
Sorry. I meant AWT.


But why AWT and not the more robust Swing?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic