Adding a specific styles to a gwt element
Is it possible to add a specific style to a gwt element??
e.g. if I have a开发者_StackOverflow中文版 button
Button X= new Button("X");
now if i want the button to be italic
can i do something like that
X.addStyleName("font-style:italic");
The styleName is only valid for an style defined in your CSS file. Check the answer from hilal for more details about it.
If you only need to specify an specific value, you can do something like
DOM.setStyleAttribute(myButton.getElement(), "fontStyle", "italic");
keep in mind that then you're hard coding these value, and any change in the style will require to recompile your code.
精彩评论