GWT RootLayoutPanel允许我们选择布局面板的起点。在此面板中, 在创建时或调整窗口大小时都会调用RequiresResize.onResize()方法。
GWT RootLayoutPanel类声明
让我们看看com.google.gwt.user.client.ui.RootLayoutPanel的声明
public class RootLayoutPanel extends LayoutPanel
GWT RootLayoutPanel方法
修饰符和类型 | 方法 | 描述 |
---|---|---|
静态RootLayoutPanel | get() | 它获取RootLayoutPanel的单例实例。 |
protected void | onLoad() | 在将小部件附加到浏览器的文档后立即调用它。 |
GWT RootLayoutPanel示例
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.user.client.Window;
/* This is the entry point method. */
public void onModuleLoad() {
// Attach two child widgets to a LayoutPanel, laying them out horizontally, splitting at 50%. Widget
childOne = new HTML("left");
Widget childTwo = new HTML("right");
LayoutPanel p = new LayoutPanel();
p.add(childOne);
p.add(childTwo);
p.setWidgetLeftWidth(childOne, 0, Unit.PCT, 50, Unit.PCT);
p.setWidgetRightWidth(childTwo, 0, Unit.PCT, 50, Unit.PCT);
// Attach the LayoutPanel to the RootLayoutPanel
RootLayoutPanel.get().add(p);
}
输出:
评论前必须登录!
注册