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.graphics.Color;
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.setBorderVisible(true);
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_DARK_SHADOW),
display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW),
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) {
System.out.println("close");
}
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
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}