There is one problem in your code. You can't refer body
directly in GWT JSNI. For more info have a look at Writing Native JavaScript Methods in GWT
Use
$doc.body.appendChild(label);
instead of
body.appendChild(label);
--EDIT--
Sample code:
label.addEventListener("mouseover", function(e) {
if (hideDelayTimer)
clearTimeout(hideDelayTimer);
label.appendChild(popup);
var labelHeight = label.offsetHeight;
var labelTop = label.offsetTop;
var windowHeight = $wnd.innerHeight;
var popupHeight = popup.offsetHeight;
if (labelTop + labelHeight + popupHeight > windowHeight) {
popup.setAttribute("style", "top:" + (labelTop - popupHeight)
+ "px");
}
});