1

我想知道是否有可能获得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。

4

2 回答 2

0

ScrollPanel sp = new ScrollPanel();

...

int innerWidth = sp.获取偏移宽度()- sp.getElement().获取滚动宽度();

...

注意: 只有当您的滚动面板连接到屏幕时,您才能使用上述代码。换句话说,它应该被渲染。

于 2013-03-16T06:53:41.610 回答
0
DOM.setStyleAttribute(scrollpanel.getElement(), "maxHeight", mMainHeight + "px");;
于 2013-04-17T06:30:17.513 回答