SWT: eclipse-like Tab

Source: Internet
Author: User

Public static void showecliplsetab (final shell)
{
Image image = new image (shell. getdisplay (), "d :\\ Program Files \ eclipsercp \ plugins \ org. Eclipse. Platform. source_4.2.1.v201209141800 \ eclipse32.png ");
Shell. settext ("copying the eclipse editing area tab ");
// Create a custom tab object
Final ctabfolder folder = new ctabfolder (shell, SWT. Border );
// Set the layout of the tab to maximize and minimize the appearance of the tab.
Folder. setlayoutdata (New griddata (SWT. Fill, SWT. Fill, true, false ));
// Set complex tabs, that is, Tab labels with rounded corners
Folder. setsimple (false );
// Set the status of unselected labels, icons, and "close" buttons
Folder. setunselectedimagevisible (true );

// Set the foreground color and background color
Folder. setselectionforeground (shell. getdisplay (). getsystemcolor (SWT. color_white ));
Folder. setselectionbackground (shell. getdisplay (). getsystemcolor (SWT. color_blue ));
// Display the "maximize" and "minimize" buttons
Folder. setmaximized (true );
Folder. setmaximizevisible (true );
Folder. setminimized (true );
Folder. setminimizevisible (true );

// Create a tab label object
For (INT I = 1; I <5; I ++)
{
Ctabitem item = new ctabitem (folder, SWT. Close );
Item. settext ("tab" + I );
Item. setimage (image );
// Place a text box in each tab
Text text = new text (folder, SWT. multi | SWT. v_scroll | SWT. h_scroll );
// The text in the text box is represented by \ n. When displayed, it is changed to the next line.
Text. settext ("this is the" + I + "Page: \ n this tab is modeled on the eclipse design \ n can be used to maximize and minimize ");
Item. setcontrol (text );
}

// Register a tab event
Folder. addctabfolder2listener (New ctabfolder2adapter (){
// Events triggered when the "minimize" button is clicked
Public void minimize (ctabfolderevent event ){
// Set the status of the tab to be minimized. The status of the tab determines the window button displayed in the upper right corner,
Folder. setminimized (true );
// Change the layout of the tab to display the minimized state.
Folder. setlayoutdata (New griddata (SWT. Fill, SWT. Fill, true, false ));
// Refresh the layout. Otherwise, the reset layout does not work.
Shell. layout (true );
}

// Events triggered when the unit clicks the "maximize" button
Public void maximize (ctabfolderevent event ){
Folder. setmaximized (true );
Folder. setlayoutdata (New griddata (SWT. Fill, SWT. Fill, true, true ));
Shell. layout (true );
}

// Events triggered when you click "Restore"
Public void restore (ctabfolderevent event)
{
Folder. setminimized (false );
Folder. setmaximized (false );
Folder. setlayoutdata (New griddata (SWT. Fill, SWT. Fill, true, false ));
Shell. layout (true );
}
});
}

Related Article

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.