You need to setSelectedTab() using the same instance that you have added to the tabsheet (“new” creates a new instance, so you can’t say “new SomeComponent()” in both addTab() and setSelectedTab()).
I would like also to select a tab, but with a button located in a component already contained in the tabsheet. Example with the following code: on panel 2, there is a button and by clicking on it, I would like to display panel 3. The page is displayed correctly, but the tab in the tab bar is not selected. Is there something wrong or missing? ver 5.2.0rc8
public class TestWindow extends Window {
private TabSheet ts;
private Panel p3;
public TestWindow() {
ts = new TabSheet();
Panel p1 = new Panel("panel 1");
Panel p2 = new Panel("panel 2");
p3 = new Panel("panel 3");
ts.addTab(p1);
ts.addTab(p2);
ts.addTab(p3);
ts.setSelectedTab(p2);
addComponent(ts);
Button b = new Button("go to panel 3");
b.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
goToPanel3();
}
});
p2.addComponent(b);
}
protected void goToPanel3() {
ts.setSelectedTab(p3);
}
}