Get active tab in SWT TabFolder

I apologize if this question is too simple, 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 these two tabs is active, as this affects the behavior of the other part of the program. Is it possible? Thank you in advance.

+4
source share
1 answer

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

If yes, add an eventlistener to your TabFolder (CTabFolder object

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

If you just have javax.swing.JTabbedPane called

 yourJTabbedPaneVariableName.getSelectedIndex() 

gives you the index of the selected tab

+6
source

Source: https://habr.com/ru/post/1286216/


All Articles