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.
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.
In worst case you can always do :
HorizontalPanel p = new HorizontalPanel();
p.getElement().getStyle().setPadding(20, Unit.PX);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With