developer.com
Search EarthWeb
CodeGuru | Gamelan | Jars | Wireless | Discussions
Navigate developer.com
Architecture & Design  
Database  
Java
Languages & Tools
Microsoft & .NET
Open Source  
Project Management  
Security  
Techniques  
Voice  
Web Services  
Wireless/Mobile
XML  
New
 
Technology Jobs  

   Developer.com Webcasts:
  The Impact of Coding Standards and Code Reviews

  Project Management for the Developer

  Defining Your Own Software Development Methodology

  more Webcasts...




See The Winners!




Developer Jobs

Be a Commerce Partner














 


Developer News -
Sun Releases NetBeans 6.7 IDE for Java, PHP    June 29, 2009
Why Firefox Doesn't Take Google Chrome Features    June 26, 2009
First Major PHP Update in Years Coming Soon    June 25, 2009
Red Hat CEO Calls on Oracle to Keep Java Open    June 25, 2009
Free Tech Newsletter -

SWT Programming with Eclipse
By Koray Guclu

Go to page: Prev  1  2  3  4  5  6  

8.3.4. TabFolder

The TabFolder widget allows users to select a page from a set of pages. Although it is a composite, it is not allowed to add composite widgets. A widget that is to be added to a TabFolder must of the TabItem type. The content of a tab can be set by using the TabItem's setControl(Control control) method.

Figure 14. TabFolder widget

A simple TabFolder example is shown below.

Source 11. TabFolder example
 final TabFolder tabFolder =
   new TabFolder( shell, SWT.BORDER);
 for (int i=1; i<5; i++)
 {
   // create a TabItem
   TabItem item = 
     new TabItem( tabFolder, SWT.NULL);
   item.setText( "TabItem " + i);
   // create a control
   Label label  =
     new Label( tabFolder, SWT.BORDER);
   label.setText( "Page " + i);
   // add a control to the TabItem
   item.setControl( label );
 }
8.3.5. CoolBar widget

The CoolBar widget provides an area in which you add items on a dynamically positionable space.You can add one or more ToolBar widgets to a CoolBar. A CoolBar can contain one or more CoolItems. Although CoolBar is a composite widget, it is not allowed to add other composite classes. Sub elements of a CoolBar must be of the CoolItem type.

Figure 15. Coolbar widget

The following example shows a CoolBar widget's usage.

Source 12. CoolBar example
  CoolBar coolBar =
    new CoolBar(shell, SWT.BORDER);
  coolBar.setLayoutData(
    new FillLayout());
  // create a tool bar which it
  // the control of the coolItem
  for (int k = 1; k <3; k++) 
  {  
    ToolBar toolBar =
      new ToolBar(coolBar, SWT.FLAT);
    for (int i = 1; i < 5; i++)
    {
      ToolItem item =
        new ToolItem(toolBar, SWT.NULL);
      item.setText("B"+k+"."+i);
    }
    // Add a coolItem to a coolBar
    CoolItem coolItem =
      new CoolItem(coolBar, SWT.NULL);
    // set the control of the coolItem
    coolItem.setControl(toolBar);
    // You have to specify the size
    Point size =
      toolBar.computeSize( SWT.DEFAULT,
                           SWT.DEFAULT);
    Point coolSize =
      coolItem.computeSize (size.x, size.y);
    coolItem.setSize(coolSize);
  }

8.4. A summary of controls having items

Some controls accept sub components as items. For example, a Composite component accepts composite components. Some components need only items. Such components are listed in Table 10.

Table 10. Components having items
Widget Item Description
CoolBar CoolItem Items are selectable, dynamically positionable areas of a CoolBar
Menu MenuItem Items are selections under a menu
TabFolder TabItem Items are Tabs in a TabFolder
Table TableItem
TableColumn
Items are Rows in a table
ToolBar ToolItem Items are Buttons on the tool bar
Tree TreeItem Items are nodes in a tree

Conclusion

SWT is the core of the Eclipse user interface. The Eclipse platform is based on the SWT library. To extend your SWT knowledge, you can download SWT examples from the SWT Web site.

About the Author


Koray Güclü

He is working as a freelance author and software architect. He is currently finishing his book on Software Architectures and Design Patterns. His main interest areas are Software Architectures, Data Warehouses, and Database Modeling.

www.korayguclu.de

Resources

Links

Books

Go to page: Prev  1  2  3  4  5  6  

Previous article: A First Look at Eclipse Plug-In Programming
Next article: Constructing SWT Layouts


Tools:
Add www.developer.com to your favorites
Add www.developer.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed


Languages & Tools Archives






internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs