PDA

View Full Version : how to add contentPanels Dynamicly



Love Yao
18 Nov 2009, 12:25 AM
in one formpanel, i input the Number.
then submit,
in another LayoutContainer , it shows the (Number) contentpanels.


the submit button:
button.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
int i = Integer.parseInt(field.getValue());
while (i > 0) {
ContentPanel contentPanel = new ContentPanel();
contentPanel.setHeading("new"+i);
contentPanel.addText("new"+i);
layContentPanel.setHeading("change");//success
layContentPanel.add(contentPanel);//no effect
i--;
}
}
});

somehow i Know the coding is wrong.
but by which way can i do it.
to add contentPanels Dynamicly.

thanks
thanks
thanks
thanks
thanks
thanks

sven
18 Nov 2009, 4:11 AM
I suggest to use the forum search or even read some threads on the same page. This was explained a couple of threads under yours.

aftter modifiny a container, you need to call layout.

Love Yao
18 Nov 2009, 5:33 PM
I konw HOW to fix itafter add my panel, layContentPanel.layout()or (before you add your text)
layContentPanel.setLayoutOnChange(true);Does Anyone know the details about it(why modifiny a container, you need to call layout)and why the setHeading success layContentPanel.setHeading("change");//success
layContentPanel.add(contentPanel);//no effect(need call layout?)

Arno.Nyhm
19 Nov 2009, 2:02 AM
with setHeading you change a already attached item -> success
with add you make a new item, but it needs to render with the layout --> no success without layout