内側のサイズを取得する可能性はあるのだろうかと思っていました
com.google.gwt.user.client.ui.ScrollPanel
GWT のオブジェクト? スクロールバーをアクティブにせずに、空のスペースに正確に収まる ScrollPanel の子を作成したいと思います。ScrollPanel は次のように初期化されます。
[@Abhijith Nagaraja の回答後に更新を開始]
public void onModuleLoad() {
Window.setMargin("0px");
TabLayoutPanel tabs = new TabLayoutPanel(30, Unit.PX);
//attach the tab panel to the body element
RootPanel.get(null).add(tabs);
//set the TabLayoutPanel to full size of the window.
String width = (Window.getClientWidth()) + "px";
String height = (Window.getClientHeight()) + "px";
tabs.setSize(width, height);
//create the scroll panel and activate the scroll bars
ScrollPanel scrollPanel = new ScrollPanel(new Button("a second button"));
scrollPanel.getElement().getStyle().setOverflowX(Overflow.SCROLL);
scrollPanel.getElement().getStyle().setOverflowY(Overflow.SCROLL);
//attach the scroll panel to the DOM
tabs.add(scrollPanel, "tab1");
System.out.println(scrollPanel.getOffsetWidth()); // --> 0
System.out.println(scrollPanel.getOffsetHeight()); // --> 0
}
【更新終了】
理由: 動的なビジュアライゼーション (後でスクロールバーが必要になる) を初期化して、見栄えがよくなり、ScrollPanel を後で追加するのを避けたいと考えています。