Add CTabFolder2Listener : CTabFolder « SWT « Java Tutorial

Add CTabFolder2Listener
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabFolder2Listener;
import org.eclipse.swt.custom.CTabFolderEvent;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class CTabFolderCTabFolder2Listener {
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Show CTabFolder");

    shell.setLayout(new GridLayout(1, true));

    CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP);
    tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Set up a gradient background for the selected tab
    tabFolder.setSelectionBackground(new Color[] {
        display.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW) }, new int[] { 50, 100 });

    new CTabItem(tabFolder, SWT.NONE, 0).setText("Tab index 1 ");
    new CTabItem(tabFolder, SWT.NONE, 1).setText("Tab index 1 ");

    tabFolder.addCTabFolder2Listener(new CTabFolder2Listener() {

      public void close(CTabFolderEvent arg0) {


      public void minimize(CTabFolderEvent arg0) {
        // TODO Auto-generated method stub


      public void maximize(CTabFolderEvent arg0) {
        // TODO Auto-generated method stub


      public void restore(CTabFolderEvent arg0) {
        // TODO Auto-generated method stub


      public void showList(CTabFolderEvent arg0) {
        // TODO Auto-generated method stub

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {

17.68.1.TabFolder/TabItem vs. CTabFolder/CTabItem
17.68.2.Creating a CTabFolder
17.68.3.Add CTabItem to CTabFolderAdd CTabItem to CTabFolder
17.68.4.Add Image to CTabFolderAdd Image to CTabFolder
17.68.5.Set CTabFolder Minimize and Maximize VisibleSet CTabFolder Minimize and Maximize Visible
17.68.6.Add CTabFolder2Adapter to CTabFolderAdd CTabFolder2Adapter to CTabFolder
17.68.7.Displaying a Gradient BackgroundDisplaying a Gradient Background
17.68.8.Add CTabFolder2ListenerAdd CTabFolder2Listener