我想知道是否有可能獲得在GWT一個GWT ScrollPanel讓孩子們的最大尺寸不滾動
com.google.gwt.user.client.ui.ScrollPanel
對象的內部尺寸?我想創建一個ScrollPanel的孩子,它完全符合空的空間,而不用激活滾動條。
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
}
[結束更新]
原因[@Abhijith納加拉賈的答案之後開始更新]:我想初始化一個動態可視化(這需要滾動條 的ScrollPanel如下初始化在稍後的時間點),這樣看起來不錯,並且避免在稍後添加ScrollPanel。
首先是滾動面板是從簡單的面板上,所以只有一個孩子可以添加,旁邊填補空白需要增加兒童的體形準確地滾動面板尺寸。希望這是你正在尋找的,如果不是,請更多地解釋它.. – Dipak 2013-03-16 04:49:27