Hi all,
TabSheet has a setSelectedTab(int) method, but no matching getSelectedTab that returns an int. I need this for some code that needs to replace a tab sheet but select the same tab (by position) that was selected before. I’ve implemented it as below in a class that contains the tab sheet being used – is there a better way I’m not seeing?
I understand the reasoning for how tab sheet currently works, but it confuses me that getSelectedTab really returns the component of the selected tab whereas getTab returns an actual tab.
public int getCurrentTab() {
final TabSheet.Tab selected = tabsheet.getTab(tabsheet.getSelectedTab());
for (int i = 0; i < tabsheet.getComponentCount(); i++) {
if (selected.equals(tabsheet.getTab(i))) {
return i;
}
}
return 0;
}
Thanks,
Bobby