I'm new to GWT, and am struggling through my first Web page with it.
I've created 2 Composite Widgets - ListWidget
and MaintenanceWidget
. When I add them both to a FlowPanel
, they both show up as they should. 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.
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.
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 ho开发者_运维问答rizontal splitter beneath it.
I've tried different configurations of the panel.add****()
method, but nothing has gotten me the results I'm looking for.
Any ideas? Thanks!
Make sure you have a doctype
declaration in your HTML template (for example, <!doctype html>
), since SplitLayoutPanel
requires browser to work in standards mode.
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. 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.
精彩评论