Glyn Glyn - 11 months ago 80
Java Question

GWT Java - set font style

I want to set the label style depending on certain input. I have found how to set the colour, font weight, font style, font size and indent. However, I can not find how to set the font family to, e.g., "Arial".

lblTaskName.getElement().getStyle().setFontSize(14.0, Unit.PT);
lblTaskName.getElement().getStyle().setTextIndent(15.0, Unit.PT);


I've seen issue withWidget#getElement()#setAttribute() in IE. The better way is:

myWidget.getElement().getStyle().setProperty("fontFamily", "Arial");

I've never tried font-family in this way. The general rule for getStyle().setProperty('camelCase','value')

camel-case becomes -> camelCase.