3

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 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.

Any ideas? Thanks!

1
  • Which widget receives that class? Commented Sep 7, 2011 at 23:44

3 Answers 3

1

Make sure you have a doctype declaration in your HTML template (for example, <!doctype html>), since SplitLayoutPanel requires browser to work in standards mode.

Sign up to request clarification or add additional context in comments.

1 Comment

I do have one. Thanks, though.
1

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!

2 Comments

You shouldn't answer your question to add more details. Just edit your question.
I meant this to be an answer - now my code works. Edited to reflect that.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.