Create a tab with a label, an image, a tool tip, and a control : TabItem « SWT « Java Tutorial






Create a tab with a label, an image, a tool tip, and a control
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;

public class TabItemWithToolTipImage {

  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER);
    for (int i = 0; i < 6; i++) {
      TabItem item = new TabItem(tabFolder, SWT.NONE);
      item.setText("TabItem " + i);
      item.setToolTipText("This is my tab" + i);
      item.setImage(new Image(display, "yourFile.gif"));
      Button button = new Button(tabFolder, SWT.PUSH);
      button.setText("Page " + i);
      item.setControl(button);
    }
    tabFolder.pack();
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    display.dispose();
  }
}








17.72.TabItem
17.72.1.Create tabs that run along the top or the bottom of the parent compositeCreate tabs that run along the top or the bottom of the parent composite
17.72.2.Create a tab with a label, an image, a tool tip, and a controlCreate a tab with a label, an image, a tool tip, and a control
17.72.3.Pass the Composite to the tab's setControl() methodPass the Composite to the tab's setControl() method
17.72.4.Add Controls to TabItemAdd Controls to TabItem
17.72.5.Add ToolTip to TabItem