PDA

View Full Version : Add widget in right side on ContentPanel



sunnyuser
24 Aug 2011, 3:56 AM
HI Guys,

I want to add child widget (ContentPanel countPanel) in right side on ContentPanel. I tried float attribute but it's not working.

Any suggestion will help me a lot to do this job.

ContentPanel panel = new ContentPanel();
panel.setHeight(24);
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
panel.setBorders(false);
panel.setLayout(new HBoxLayout());

TextField<String> searchField = new TextField<String>();
searchField.setHeight(24);
searchField.setWidth(75);
panel.add(searchField);

Label goButton = new Label("Go");

panel.add(goButton);

populateAlphanPanel(panel);

final ContentPanel countPanel = new ContentPanel();
countPanel.setHeight(24);
countPanel.setHeaderVisible(false);
countPanel.setBodyBorder(false);
countPanel.setBorders(false);
countPanel.setLayout(new FitLayout());

Label countLabel = new Label(getCountStr(0, 0, 0));
countLabel.setHeight(24);

countPanel.add(countLabel);
countPanel.setStyleAttribute("float", "right");

panel.add(countPanel);
RootPanel.get().add(panel);

In this example, I want to add countPanel in the right side of panel.

with warm regards,

Sunny.

vtysh
24 Aug 2011, 4:52 AM
I see you are using HBoxLayout. Here you can find examples of usage http://www.sencha.com/examples/#hboxlayout
You can add some flex Text first and then your countPanel to the main panel

HBoxLayoutData flex = new HBoxLayoutData(new Margins(0, 5, 0, 0));
flex.setFlex(1);
panel.add(new Text(), flex);
panel.add(countPanel);

Also you can use combinations of border layout and some other layout to add necessary panel to the east

sunnyuser
24 Aug 2011, 8:10 AM
HI,

I tried BorderLayoutDate but it didn't work for me...

Please look this code :

BorderLayoutData borderBorderLayoutData = new BorderLayoutData(LayoutRegion.EAST);
panel.add(countPanel, borderBorderLayoutData);
RootPanel.get().add(panel);

vtysh
24 Aug 2011, 9:25 PM
Do you have this line?

panel.setLayout(new BorderLayout());