Cannot find window with index: '1'

I found a similar discussion:

The following fragment would be interesting:

int currentTab = WebUI.getWindowIndex()
...
WebUI.switchToWindowIndex(currentTab + 1)