Search code examples
javaswtctabitem

SWT CTabFolder Check If CTAB Exists


I am trying to create a tab inferface for my application in SWT. I would like to setup my menu button so that when it is clicked it check to see if a tab is open. If it is open I want to switch to the tab and if it is not I want to open it. I have already created a menu item that will create the tab, but I am unsure how to check to see if the tab exists.


Solution

  • public static Boolean CtabExists(CTabFolder folder, CTabItem tab) {
        if (tab != null) {
            int intIndex = -1;
            intIndex = folder.indexOf(tab);
            if (intIndex == -1) {
                return false;
            } else {
                return true;
            }
        } else {
            return false;
        }
    }