Source:
<code>protected void onInitUI() { super.onInitUI(); createWidgets(); final Grid grid = new Grid(2, 2); grid.setStyleName(Gerrit.RESOURCES.css().infoBlock()); grid.setText(0, 0, Util.C.watchedProjectName()); grid.setWidget(0, 1, nameTxt); grid.setText(1, 0, Util.C.watchedProjectFilter()); grid.setWidget(1, 1, filterTxt); final CellFormatter fmt = grid.getCellFormatter(); fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost()); fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost()); fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().header()); fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().header()); fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().bottomheader()); final FlowPanel fp = new FlowPanel(); fp.setStyleName(Gerrit.RESOURCES.css().addWatchPanel()); fp.add(grid); fp.add(addNew); fp.add(browse); add(fp); add(watchesTab); add(delSel); FlowPanel pfp = new FlowPanel(); <START> pfp.add(new ScrollPanel(projectsTab)); <END> pfp.add(close); popup.setWidget(pfp); popupPosition = new PopupPanel.PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int top = grid.getAbsoluteTop() - 50; int left = 5 + Math.max( grid.getAbsoluteLeft() + grid.getOffsetWidth(), watchesTab.getAbsoluteLeft() + watchesTab.getOffsetWidth() ); if (top + offsetHeight > Window.getClientHeight()) { top = Window.getClientHeight() - offsetHeight; } if (left + offsetWidth > Window.getClientWidth()) { left = Window.getClientWidth() - offsetWidth; } popup.setPopupPosition(left > 0 ? left : 0 , top > 0 ? top : 0); } }; }</code><technical_language>I explicitly set a height for scroll pane, a long list of projects vertical scroll bar popup out of screen. PatchBrowserPopup I a height for scroll pane is set there. In PatchBrowserPopup onResize(ResizeEvent) method is implemented adapt popup size resize. need do here</technical_language>

Target:
protected void onInitUI() { super.onInitUI(); createWidgets(); final Grid grid = new Grid(2, 2); grid.setStyleName(Gerrit.RESOURCES.css().infoBlock()); grid.setText(0, 0, Util.C.watchedProjectName()); grid.setWidget(0, 1, nameTxt); grid.setText(1, 0, Util.C.watchedProjectFilter()); grid.setWidget(1, 1, filterTxt); final CellFormatter fmt = grid.getCellFormatter(); fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost()); fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost()); fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().header()); fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().header()); fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().bottomheader()); final FlowPanel fp = new FlowPanel(); fp.setStyleName(Gerrit.RESOURCES.css().addWatchPanel()); fp.add(grid); fp.add(addNew); fp.add(browse); add(fp); add(watchesTab); add(delSel); final FlowPanel pfp = new FlowPanel(); sp = new ScrollPanel(projectsTab); pfp.add(sp); pfp.add(close); popup.setWidget(pfp); popupPosition = new PopupPanel.PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { if (preferredPopupWidth == -1) { preferredPopupWidth = offsetWidth; } int top = grid.getAbsoluteTop() - 50; int left = 5 + Math.max( grid.getAbsoluteLeft() + grid.getOffsetWidth(), watchesTab.getAbsoluteLeft() + watchesTab.getOffsetWidth() ); if (top + offsetHeight > Window.getClientHeight()) { top = Window.getClientHeight() - offsetHeight; } if (left + offsetWidth > Window.getClientWidth()) { left = Window.getClientWidth() - offsetWidth; } if (top < 0) { sp.setHeight((sp.getOffsetHeight() + top) + "px"); top = 0; } if (left < 0) { sp.setWidth((sp.getOffsetWidth() + left) + "px"); left = 0; } popup.setPopupPosition(left, top); } }; }