Tab content does not display while closing the un-selected tab.

I have a tabsheet and there are tabs set closable. While one tab is focused, as tab1, no content displayed on tab1 after I closed other tab, as tab2.

So how can I fix this bug.

What’s more , Actually, if a tab to be closed is not the last tab in the tabsheet, all tabs after it will have a display problem.

What I did is to remove all tabs and add the tabs again.

@Override
    public void onTabClose(TabSheet tabsheet, Component tabContent) {
	...
        ...
	tabsheet.removeComponent(tabContent);
	Component c = tabsheet.getSelectedTab();
	List<Tab> cs = new ArrayList<Tab>();
	
	for (int i = 0; i < tabsheet.getComponentCount(); i++) {
	    if (!tabsheet.getTab(i).getComponent().equals(tabContent))
		cs.add(tabsheet.getTab(i));
	}

	tabsheet.removeAllComponents();

	for (int j = 0; j < cs.size(); j++) {
	    String cString = cs.get(j).getCaption();
	    tabsheet.addTab(cs.get(j).getComponent());
	    //tab.setCaption(cString);
	}
	tabsheet.setSelectedTab(c);
    }

But the line tabsheet.addTab(cs.get(j).getComponent()); returns npe;

Thanks.

  • K

Is there anybody can help? :frowning:

    public void onTabClose(TabSheet tabsheet, Component tabContent) {
        
        tabsheet.removeComponent(tabContent);
        try {
            Thread.sleep(100);
        } catch (InterruptedException ex) {
            Logger.getLogger(HelloWorld.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

This “wait” workaround works for me.

This is not a clean solution, i’m searching for a better way.

It seems a rendering problem or a cascading events problem.

Bye,

Agharta

If you suspect a bug, please file a report at
http://dev.vaadin.com
that includes a simple test case (a single Application class will do nicely).

Alredy done, but no response.

http://dev.vaadin.com/ticket/7686

Hi,

I tested your code, even if the line " Thread.sleep(100);" is commented, it is also working correctly. However, with this line added into my project. the issue is not fixed. existing still.

Thanks,
Chun