I have a panel and inside the panel i have components arranged in hbox layout. Say

Panel
hbox:1
hbox:2
hbox:3
Now when i remove hbox2 dynamically and perform panel.doLayout(), the below error is displayed in firebug,
"Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLFormElement.insertBefore]"
The corresponding hbox gets removed from panel items. But the panel cannot be recalculated using doLayout. Any ideas?