Java – Get Active Tab in SWT TabFolder


I apologize if this question is too basic, but I just can't figure out how to do this. I have a SWT TableFolder with two tabs, and I need to determine which of those two tabs are currently active, as it effects the behavior of another part of the program. Is this possible? Thank you in advance.

Best Solution

To you mean the org.eclipse.swt.widgets.TabFolder (CTabFolder)?

If yes add an eventlistener to your TabFolder(CTabFolder object

tabFolder.addSelectionListener(new SelectionAdapter() {
  public void widgetSelected( event) {
    tabFolder.getSelection()[0]; // This should be your TabItem/CTabItem

If you simply have a javax.swing.JTabbedPane then calling


gives you the index of the selected Tab