SWT: Tab

Source: Internet
Author: User

// Todo auto-generated method stub

Display display = display. getdefault ();
Shell shell = new shell (Display );
Shell. setlayout (New filllayout (SWT. Vertical ));

// Create a tabfolder object
// A tab folder (tabfolder) consists of one or more options (tabitem)
// A tabfolder consists of one or more tabitems, which are one-to-many relationships.
// Tabitem uses the setcontrol (Control) method to set the control display.
// Controls controlled by tabitem can be basic components or panel containers.
// The tab is placed at the bottom of the style: SWT. Bottom
// Final tabfolder = new tabfolder (shell, SWT. Bottom );
Final tabfolder = new tabfolder (shell, SWT. Top );
// Set the tab Layout
Tabfolder. setlayout (New filllayout ());
For (INT I = 1; I <4; I ++)
{
// Create a tabitem tab label object
Tabitem item = new tabitem (tabfolder, SWT. None );
// Set the text of the tab
Item. settext ("tab" + I );
Text T = new text (tabfolder, SWT. multi );
T. settext ("this is the" + I + "page ");
// Set the control controlled by the tab
Item. setcontrol (t );

// Create a tab icon
// Image = new image (display, PATH );
// Item. setimage (image );
}

Tabfolder. Pack ();

Shell. open ();
While (! Shell. isdisposed ())
{
If (! Display. readanddispatch ())
{
Display. Sleep ();
}
}

Display. Dispose ();

// Common tab Methods
// Obtain the tab of the specified index: tabitem getitem (INT index)
// Obtain the total number of tabs. The returned value is int: getitemcount ();
// Obtain the selected card array: getitems ();
// Obtain the Selected tab: getselection ()
// Obtain the index value of the currently selected tab. Return Value: INT: getselectionindex ();
// Check whether the specified option exists. INT: indexof (tabitem item) is returned. If so, the return tab is displayed.
// The index value. If the index does not exist,-1 is returned.
// Set the Selected tab: setselection (tabitem [] items );
// Setselection (INT index)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.