PDA

View Full Version : [FIXED] ContentPanel.setTopComponent() & ContentPanel.setBottomComponent() combined



ricardocampos
23 May 2008, 10:33 AM
Hi!

There seems to be a layout problem when I use ContentPanel.setTopComponent() & ContentPanel.setBottomComponent() at the same time... Shouldn't it be possible to do it?

Example:

...

ContentPanel panel =

new ContentPanel();
panel.setHeading("Tasks");
panel.setFrame(true);
panel.setSize(700, 300);
panel.setPagePosition(100, 100);
panel.setLayout(new FitLayout());
panel.setShadow(true);
panel.setTopComponent(loadTopToolBar());
panel.add(loadTable());

panel.setBottomComponent(loadBottomToolBar());
...

darrellmeyer
2 Jun 2008, 9:53 PM
You should be able to use both. This code works fine with beta 4:


public void onModuleLoad() {
ContentPanel cp = new ContentPanel();
cp.setFrame(true);
cp.setSize(500, 400);
cp.setLayout(new FitLayout());

LayoutContainer c = new LayoutContainer();
c.setBorders(true);
cp.add(c);

cp.setTopComponent(new ToolBar());
cp.setBottomComponent(new ToolBar());

RootPanel.get().add(cp);
}When posting code, it is helpful if the code sample is complete and can be executed.

gbegley
25 Aug 2010, 11:25 AM
I had a bit of trouble extending content panel with top and bottom components :-? and came to the realization that top and bottom components cannot be set after the parent class's onRender has been called. The solution was simply to add top/bottom components prior to calling the super method.


public class MyPagingToolContent extends ContentPanel {

ToolBar toolBar = new ToolBar();
PagingToolBar pagingToolBar = new PagingToolBar(50);

@Override
protected void onRender(Element parent, int pos) {
setTopComponent(toolBar);
setBottomComponent(pagingToolBar);
super.onRender(parent, pos);
setupTools();
setFrame(true);
setLayout(new FillLayout());

}
}