Dynamically resizing a webToolBar

Is it possible to know the position and width of the last element inserted in a webToolBar (not docked) to resize the webToolBar dynamically?