This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
When should they be used, respectively? They seem very similar to me.
Pavan Kumar Srinivasan
Greenhorn
Joined: Sep 17, 2008
Posts: 26
posted
0
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
posted
0
Sorry. I meant AWT.
Brian Cole
Author
Ranch Hand
Joined: Sep 20, 2005
Posts: 852
posted
0
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.