Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT HorizontalPanel setSpacing?

Is there a way to set padding on GWT's HorizontalPanel?

I wanted to just have 20px left padding and then add few buttons.
Currently I can only add setSpacing() and that puts padding on top, left, right and bottom.

like image 382
aadidasu Avatar asked Jun 13 '10 01:06

aadidasu


2 Answers

You could (and should) use CSS for this, something like:

.paddedHorizontalPanel {
    padding-left: 20px;
}

And if you want every Button in that HorizontalPanel to be 20px apart, then you can try this instead:

.paddedHorizontalPanel .gwt-Button {
    margin-left: 20px;
}

And then add this style to you HorizontalPanel via hPanel.addStyleName("paddedHorizontalPanel"); More on CSS and GWT in the docs.

PS: AFAIK, not including setPadding was a concious choice on part of the GWT team - they wanted to leave the styling of the application entirely up to CSS.

like image 64
Igor Klimer Avatar answered Sep 23 '22 08:09

Igor Klimer


In worst case you can always do :

HorizontalPanel p = new HorizontalPanel();
p.getElement().getStyle().setPadding(20, Unit.PX);
like image 32
davgut Avatar answered Sep 21 '22 08:09

davgut