[英]GWT widget not showing when I use a SplitLayoutPanel
I'm new to GWT, and am struggling through my first Web page with it. 我是GWT的新手,我正在努力完成我的第一个网页。
I've created 2 Composite Widgets - ListWidget
and MaintenanceWidget
. 我创建了2个Composite Widgets -
ListWidget
和MaintenanceWidget
。 When I add them both to a FlowPanel
, they both show up as they should. 当我将它们都添加到
FlowPanel
,它们都会显示出来。 However, when I try to use a SplitLayoutPanel
, depending on how I do it, either none of them show or only one of them shows. 但是,当我尝试使用
SplitLayoutPanel
,取决于我是如何操作的,要么它们都没有显示,要么只显示其中一个。
Below is my code: 以下是我的代码:
public MainPanel(){
list = new ListWidget();
maintenance = new MaintenanceWidget();
panel = new SplitLayoutPanel();
panel.addWest(list, 200);
panel.addNorth(maintenance, 250);
initWidget(panel);
}
In my entry point onModuleLoad() method, I create an instance of MainPanel
and add it to the root pane. 在我的入口点onModuleLoad()方法中,我创建了一个
MainPanel
实例并将其添加到根窗格。
With this code, I get a blank space in the west where the list should be, and the maintenance widget on the top with a horizontal splitter beneath it. 使用此代码,我在列表应该位于的西部有一个空白区域,顶部有一个维护小部件,下面有一个水平分割器。
I've tried different configurations of the panel.add****()
method, but nothing has gotten me the results I'm looking for. 我已经尝试了
panel.add****()
方法的不同配置,但没有任何东西让我得到我正在寻找的结果。
Any ideas? 有任何想法吗? Thanks!
谢谢!
确保HTML模板中有doctype
声明(例如, <!doctype html>
),因为SplitLayoutPanel
要求浏览器在标准模式下工作。
I found some sample code here that used a method that I hadn't seen before. 我在这里找到了一些示例代码,它使用了我之前从未见过的方法。
My code now reads as follows: 我的代码现在如下所示:
public MainPanel(){
list = new ListWidget();
maintenance = new MaintenanceWidget();
panel = new SplitLayoutPanel();
panel.setPixelSize(500, 400);
panel.addWest(list, 200);
panel.add(maintenance);
initWidget(panel);
}
And now it works. 现在它有效。 Thanks for your help!
谢谢你的帮助!
If not mistaken, SpliLayoutPanel must be attached to the body of the document. 如果没有弄错,SpliLayoutPanel必须附加到文档的正文。 Try something like:
尝试类似的东西:
public void onModuleLoad() {
SplitLayoutPanel panel = new SplitLayoutPanel();
panel.addWest(new Label("WEST"), 50);
panel.addNorth(new Label("NORTH"), 50);
panel.addEast(new Label("EAST"), 50);
panel.addSouth(new Label("SOUTH"), 50);
panel.add(new Label("CONTENT HERECONTENT HERECONTENT HERECONTENT HERECONTENT HERECONTENT HERE"));
RootLayoutPanel.get().add(panel); //This gets the body element and attaches itself to it, then adds panel.
}
Shouldn't be too hard to apply it to your code. 不应该太难将它应用到您的代码中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.