I have a tabs
for a wizard process.
Is it possible to achieve that if certain conditions are not met, avoid proceeding to the next step (avoid switching to the next tab)?
Could I achieve my requirement in the SelectionListener
?
SelectionListener
is problematic as it's a little too late and doesn't provide us with an object we can use.
First disable the swipe action by using setSwipeActivated(false);
.
Swiping is a bit problematic to block as it provides a preview of the next tab.
You can override setSelectedIndex(int, boolean)
to return in such a case. Alternatively you can do something like this:
private void enableTabs(Tabs t, boolean enable) {
for(Component c : t.getTabsContainer()) {
c.setEnabled(enable);
}
}
Then use enableTabs(t, false)
to disable all the tabs and use true
later to re-enable them.