Saturday, June 5, 2010

Re: building a gui with different panels - nothing works...

If you want to have nested Layout Panels, they need to be inside the
"Layout" family. Otherwise they will not render well.
So instead of using a SimplePanel, if u expect to attach another
Layout use LayoutPanel.

Note the LayoutPanel middle...

public class TestLayout implements EntryPoint {

public void onModuleLoad() {
DockLayoutPanel pnl = new DockLayoutPanel(Unit.PX);
pnl.setSize("100%", "100%");
pnl.addNorth(createPanel("#f00"), 20);
pnl.addSouth(createPanel("#ff0"), 20);
pnl.addWest(createPanel("#fff"), 20);
pnl.addEast(createPanel("#0f0"), 20);

LayoutPanel middle = new LayoutPanel();
pnl.add(middle);

MenuBar mnb = new MenuBar(true);
mnb.addItem("Test", new Command() {
public void execute() {
System.out.println("test");
}
});
DockLayoutPanel p = new DockLayoutPanel(Unit.PX);
p.addNorth(mnb, 100); // 100 is hardcoded = unwanted
p.addSouth(createPanel("#0ff"), 20);
p.addWest(createPanel("#00f"), 20);
p.addEast(createPanel("#f0f"), 20);
middle.add(p);
RootLayoutPanel root = RootLayoutPanel.get();
root.add(pnl);
}

SimplePanel createPanel(String color) {
SimplePanel panel = new SimplePanel();
panel.getElement().getStyle().setBackgroundColor(color);
return panel;
}
}


On Jun 5, 7:47 pm, Magnus <alpineblas...@googlemail.com> wrote:
> Hi,
>
> I am new to GWT and I expected to get methods to build nice web 2.0
> guis. However, I am somewhat disappointed. I try to build a gui with
> the different layouts, nested and combined them, but nothing really
> works, i. e. nothing does what I am expecting it to do.
>
> The following is just an example:
>
> I would like an outer DockLayoutPanel, which occupies the whole
> window:
>
>  DockLayoutPanel pnl = new DockLayoutPanel (Unit.PX);
>  pnl.setSize ("100%","100%");
>  pnl.addNorth (new SimplePanel (),20);
>  pnl.addSouth (new SimplePanel (),20);
>  pnl.addWest (new SimplePanel (),20);
>  pnl.addEast (new SimplePanel (),20);
>
> Then, I would like an inner DockLayoutPanel, which has a MenuBar at
> its north, and the main content in its center:
>
>   MenuBar mnb = new MenuBar (true);
>   mnb.add ...
>
>   DockLayoutPanel p = new DockLayoutPanel (Unit.PX);
>   p.addNorth (mnb,100); // 100 is hardcoded = unwanted
>   p.addSouth (new SimplePanel (),mtr_Border);
>   p.addWest (new SimplePanel (),mtr_Border);
>   p.addEast (new SimplePanel (),mtr_Border);
>
>   pnl.add(p);
>
>   RootLayoutPanel root = RootLayoutPanel.get();
>   root.add (pnl);
>
> This does not work: The MenuBar is not visible.
>
> It seems that a DockLayoutPanel never works within another panel.
>
> Well, nothing works. So GWT does not make any fun.
> Please help me!
>
> Magnus

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate