📅  最后修改于: 2021-01-02 12:44:43             🧑  作者: Mango
GWT RootLayoutPanel允许我们选择布局面板的起点。在此面板中,在创建时或调整窗口大小时都会调用RequiresResize.onResize()方法。
让我们看看com.google.gwt.user.client.ui.RootLayoutPanel的声明
public class RootLayoutPanel extends LayoutPanel
Modifier and Types | Method | Description |
---|---|---|
static RootLayoutPanel | get() | It gets the singleton instance of RootLayoutPanel. |
protected void | onLoad() | It is called immediately after a widget becomes attached to the browser’s document. |
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);
}
输出: