PDA

View Full Version : How to horizontally align widgets in ContentPanel?



francescoNemesi
15 Oct 2008, 7:22 AM
Hi Guys,

I am creating a custom widget made of a Button and ComboBox. The code goes like this



widgetContentPanel.setHeaderVisible(false);
widgetContentPanel.setHeight(50);
widgetContentPanel.setBodyBorder(false);

button.setText(textConstants.AddTo());
comboBox.setDisplayField("role");
comboBox.setWidth(150);
comboBox.setStore(listStore);
comboBox.setEditable(false);
comboBox.setValue(listStore.getAt(1));

widgetContentPanel.add(button);
widgetContentPanel.add(comboBox);
this.initWidget(widgetContentPanel);


By doing this the button and the comboBox are aligned vertically. How do I make them aligned horizontally so that they are "on the same line" with the button to the left of the comboBox?

Thanks for any reply

Francesco

eugenparaschiv
15 Oct 2008, 10:42 PM
Try using a RowLayout(Orientation.Horizontal) and then add the items to the panel like this:
panel.add(item, new RowData(...))

francescoNemesi
16 Oct 2008, 12:00 AM
Thanks! That did the trick.



widgetContentPanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
widgetContentPanel.add(button,new RowData(70,25));
widgetContentPanel.add(comboBox,new RowData(150,25));


Kind regards,
Francesco