• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 10. SWT Composites and Groups > Subclassing the Composite Class

10.1. Subclassing the Composite Class

One major difference between the Composite and Shell classes is that Composite may be subclassed. Perhaps you have noticed that in every example so far, an instance of Shell was created within another class, and then widgets were added to that instance. The object-oriented purist may have expected to create a subclass of Shell and then create widgets within that subclass.

With Shell (and many of the SWT widget classes), you are not permitted to create a subclass, so the pure object-oriented approach isn't available. This is not true with Composite. With Composite, you can create a class that extends Composite, add widgets to that class, then add an instance of your custom class to an instance of Shell. This enables you to use Composite descendants to create reusable custom user-interface elements, such as a standard login prompt, for use in more than one application.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint