我想知道是否有可能获得a的内部尺寸
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。