Search code examples
javagxt

Change tab with button in TabPanel


I'm working on a school project an have created a GXT TabPanel as follows:

TabPanel tabPanel = new TabPanel();

tabPanel.add(initMyModelView(), "My Model");
tabPanel.add(initGroupModelView(), "Group Model");
tabPanel.add(initProposalView(), "Proposals");  
tabPanel.add(initPreferencesView(), "Preferences");

In groupmodel I have a TextButton, when clicking this I want to change to the "My Model" tab.

exportModelButton.addSelectHandler(new SelectHandler(){

        @Override
        public void onSelect(SelectEvent event) {
            // TODO Auto-generated method stub

        }

    });

Could this be done in GXT 3.1.0 and if so, how?


Solution

  • Try this

    tabpanel.setActiveWidget(tabPanel.getWidget(index));
    

    This uses the index of the items, added to it. You can write your own method that returns the particular Widget (returned by initMyModelView()).