About Awt
1 posts in topic
Flat View  Flat View

Posted By:   Ramji_KN
Posted On:   Thursday, February 6, 2003 10:24 PM

What is the Difference between canvas and frame in java?

Re: About Awt

Posted By:   Bahman_Barzideh  
Posted On:   Friday, February 7, 2003 07:53 AM

A frame is the window for you application. It holds all components
for your application. A canvas is a component, same as a TextField
or CheckBox is. If you where developing a paint program you might use a to trap the user's inputs and draw the objects (lines, circles, boxes, etc.) that a user requests. To display the Canvas you would put it in a Frame.

From your question, I am guessing you are just about
to develop your first GUI app in java. if so, I would suggest a few things:
  • You most likely do not need a Canvas class.
  • You will almost certainly need to have a Frame. This
    is the object you will put all your Components (text fields, buttons, drop
    downs, lists, etc.) into and display them. It is also the component that
    draws your window tilte and decorations (resizing, iconify, maximize,
    etc). for you.

  • Generally you should prefer to use Swing over AWT unless you have a
    good reason not to. Swing can be much more efficient and
    there is a Swing component for each AWT component. For example use a JFrame instead of a Frame and a JCanvas where you would use
    a Canvas). But be wary of using both Swing and AWT components in the
    same app.

  • A basic intro to the world of JFC/Swing might be usefull. You can try http://java.sun.com/docs/books/tutorial/uiswing on the sun web site.
  • About | Sitemap | Contact