为什么这个GWT DockLayoutPanel的对话框大小如此之小? [英] Why is the dialog size so small with this GWT DockLayoutPanel?
问题描述
我已经使用GWT 2.0.4生成了一个新的Web应用程序项目。我替换onModuleLoad()代码:
I've generated a new Web Application project using GWT 2.0.4. I replace the onModuleLoad() code with:
public void onModuleLoad() {
DockLayoutPanel dp = new DockLayoutPanel(Unit.EM);
dp.addNorth(new Button("north search"), 4);
dp.addSouth(new Button("Search"), 4);
dp.addWest(new Button("west"), 4);
dp.addEast(new Button("east"), 4);
RootLayoutPanel.get().add(dp);
}
这产生了我认为是正确的事情;四个按钮,每个边缘一个。但是,如果我尝试将这个完全相同的东西放在一个DialogBox里面,就像这样:
That produces what I think is the right thing; four buttons, one on each edge. But if I try to put that exact same thing into a DialogBox like this:
public void onModuleLoad() {
DockLayoutPanel dp = new DockLayoutPanel(Unit.EM);
dp.addNorth(new Button("north search"), 4);
dp.addSouth(new Button("Search"), 4);
dp.addWest(new Button("west"), 4);
dp.addEast(new Button("east"), 4);
DialogBox dlog = new DialogBox();
dlog.add(dp);
dlog.show();
}
我得到的是一个小小的对话框,右拐角按钮在那里,但它们只有几个像素宽。
What I get is a tiny little dialog box squished up in the right hand corner. The buttons are there but they're only a few pixels wide.
为什么?我究竟做错了什么?对话框不应该与普通窗口非常相似吗?
Why? What am I doing wrong? Shouldn't the dialog box have something very similar to the normal window?
推荐答案
RootLayoutPanel专门用于封装LayoutPanels并照顾至少在一定程度上调整尺寸等。如果要在一个正常的Widget中包装一个LayoutPanel,您需要显式设置面板的大小:
RootLayoutPanel is specifically designed to wrap LayoutPanels and takes care of sizing etc. at least to a certain extent. If you want to wrap a LayoutPanel in a normal Widget, you need to set the size of the panel explicitly:
DockLayoutPanel dp = new DockLayoutPanel(Unit.EM);
dp.addNorth(new Button("north search"), 4);
dp.addSouth(new Button("Search"), 4);
dp.addWest(new Button("west"), 4);
dp.addEast(new Button("east"), 4);
dp.setSize("20em", "20em");
DialogBox dlog = new DialogBox();
dlog.add(dp);
dlog.show();
看看是否有帮助!祝你好运!
See whether that helps! Good luck!
这篇关于为什么这个GWT DockLayoutPanel的对话框大小如此之小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!