Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / June 2005

Tip: Looking for answers? Try searching our database.

Does anyone know the exact difference between a SWT Canvas and a SWT Composite?

Thread view: 
caroarce@gmail.com - 07 Jun 2005 22:31 GMT
I have been trying to draw shapes on a SWT Composite and apparently
this is not possible. I can draw over a Shell or a SWT Canvas. But
drawing over a Composite does not work.

Canvas extends from Composite and looking at the source code I can se
it adds very little behaviour to composite.

All the documentation and articles I have been reading suggest that you
should draw on a Canvas, but it also says that any control that can
return a GC is available for drawing. A composite does return a GC ...

Therefore I'm wondering if my problem with the Composite is a bug of if
drawing on it is not allowed, and if a Canvas should be only used for
painting.

Thanks in advance for the help and tips you can provide me :)

Caro
Andrew Thompson - 07 Jun 2005 22:51 GMT
Re: Does anyone know the exact difference between a SWT Canvas and a SWT
Composite?

I have never used SWT before, but I have a wild guess
after a little Googling..  (I must be bored!)

<http://www.eclipse.org/documentation/html/plugins/org.eclipse.platform.doc.isv/d
oc/reference/api/org/eclipse/swt/widgets/Composite.html#computeSize(int,%20int,%
20boolean
)>
Computes the size of a Composite (which seems to be the rough equivalent of
an AWT Container), a container in the AWT calulates its preferred size from
the (combined) sizes of the components within it.

If you have *no* components in it, its preferred size is 0x0.
(and that is how big it ends up in the GUI)

The (org.eclipse.swt.widgets.)Canvas is meant to be drawn to, and
probably has a mechanism to ensure it has a minimum size, whereas
the Composite does not.

HTH

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

caroarce@gmail.com - 08 Jun 2005 13:41 GMT
Andrew, Thanks for your reply! After I looked a bit more at the source
code I have arrived to almost the same conclusion. I looks like a
Canvas is the equivalent of a Panel in source code, though apparently
eclipse developers encourage you to use Composites, in places where in
Swing you would use a Panel...

Caro


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.